mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:58:59 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into sysTray
This commit is contained in:
commit
aba183b165
22 changed files with 2368 additions and 2269 deletions
83
interface/resources/icons/tablet-icons/people-a-msg.svg
Normal file
83
interface/resources/icons/tablet-icons/people-a-msg.svg
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 50 50"
|
||||||
|
style="enable-background:new 0 0 50 50;"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg2"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="people-a.svg"><metadata
|
||||||
|
id="metadata24"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs22" /><sodipodi:namedview
|
||||||
|
pagecolor="#ff0000"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="852"
|
||||||
|
inkscape:window-height="480"
|
||||||
|
id="namedview20"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="4.72"
|
||||||
|
inkscape:cx="25"
|
||||||
|
inkscape:cy="25"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="svg2" /><style
|
||||||
|
type="text/css"
|
||||||
|
id="style4">
|
||||||
|
.st0{fill:#FFFFFF;}
|
||||||
|
.st1{fill:#EF3B4E;}
|
||||||
|
</style>
|
||||||
|
<circle class="st1" cx="44.1" cy="6" r="5.6"/>
|
||||||
|
<g
|
||||||
|
id="Layer_2" /><g
|
||||||
|
id="Layer_1"
|
||||||
|
style="fill:#000000;fill-opacity:1"><circle
|
||||||
|
class="st0"
|
||||||
|
cx="25.6"
|
||||||
|
cy="14.8"
|
||||||
|
r="8.1"
|
||||||
|
id="circle8"
|
||||||
|
style="fill:#000000;fill-opacity:1" /><path
|
||||||
|
class="st0"
|
||||||
|
d="M31.4,27h-11c-4.6,0-8.2,3.9-8.2,8.5v4.3c3.8,2.8,8.1,4.5,13.1,4.5c5.6,0,10.6-2.1,14.4-5.6v-3.2 C39.6,30.9,35.9,27,31.4,27z"
|
||||||
|
id="path10"
|
||||||
|
style="fill:#000000;fill-opacity:1" /><circle
|
||||||
|
class="st0"
|
||||||
|
cx="41.6"
|
||||||
|
cy="17.1"
|
||||||
|
r="3.5"
|
||||||
|
id="circle12"
|
||||||
|
style="fill:#000000;fill-opacity:1" /><path
|
||||||
|
class="st0"
|
||||||
|
d="M43.9,23.9h-4.1c-0.9,0-1.7,0.4-2.3,1c1.2,0.6,2.3,1.6,3.1,2.5c1,1.2,1.5,2.7,1.7,4.3c0.3,0.9,0.4,1.8,0.2,2.8 v0.6c1.6-2.2,3.3-6,4-8.1v-0.3C46.5,25.7,45.3,23.9,43.9,23.9z"
|
||||||
|
id="path14"
|
||||||
|
style="fill:#000000;fill-opacity:1" /><circle
|
||||||
|
class="st0"
|
||||||
|
cx="9.4"
|
||||||
|
cy="18"
|
||||||
|
r="3.5"
|
||||||
|
id="circle16"
|
||||||
|
style="fill:#000000;fill-opacity:1" /><path
|
||||||
|
class="st0"
|
||||||
|
d="M8.5,35.7c-0.1-0.7-0.1-1.4,0-2.1l0.1-0.2c0-0.2,0-0.4,0-0.6c0-0.2,0-0.3,0.1-0.5c0-0.2,0-0.3,0-0.5 c0.2-2.1,1.6-4.4,3.2-5.7c0.4-0.4,0.9-0.6,1.4-0.9c-0.5-0.5-1.3-0.7-2-0.7H7c-1.4,0-2.6,1.8-2.4,2.7v0.3 C5.1,29.8,6.8,33.5,8.5,35.7z"
|
||||||
|
id="path18"
|
||||||
|
style="fill:#000000;fill-opacity:1" /></g></svg>
|
After Width: | Height: | Size: 2.9 KiB |
24
interface/resources/icons/tablet-icons/people-i-msg.svg
Normal file
24
interface/resources/icons/tablet-icons/people-i-msg.svg
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#FFFFFF;}
|
||||||
|
.st1{fill:#EF3B4E;}
|
||||||
|
</style>
|
||||||
|
<circle class="st1" cx="44.1" cy="6" r="5.6"/>
|
||||||
|
<g id="Layer_2">
|
||||||
|
</g>
|
||||||
|
<g id="Layer_1">
|
||||||
|
<circle class="st0" cx="25.6" cy="14.8" r="8.1"/>
|
||||||
|
<path class="st0" d="M31.4,27h-11c-4.6,0-8.2,3.9-8.2,8.5v4.3c3.8,2.8,8.1,4.5,13.1,4.5c5.6,0,10.6-2.1,14.4-5.6v-3.2
|
||||||
|
C39.6,30.9,35.9,27,31.4,27z"/>
|
||||||
|
<circle class="st0" cx="41.6" cy="17.1" r="3.5"/>
|
||||||
|
<path class="st0" d="M43.9,23.9h-4.1c-0.9,0-1.7,0.4-2.3,1c1.2,0.6,2.3,1.6,3.1,2.5c1,1.2,1.5,2.7,1.7,4.3c0.3,0.9,0.4,1.8,0.2,2.8
|
||||||
|
v0.6c1.6-2.2,3.3-6,4-8.1v-0.3C46.5,25.7,45.3,23.9,43.9,23.9z"/>
|
||||||
|
<circle class="st0" cx="9.4" cy="18" r="3.5"/>
|
||||||
|
<path class="st0" d="M8.5,35.7c-0.1-0.7-0.1-1.4,0-2.1l0.1-0.2c0-0.2,0-0.4,0-0.6c0-0.2,0-0.3,0.1-0.5c0-0.2,0-0.3,0-0.5
|
||||||
|
c0.2-2.1,1.6-4.4,3.2-5.7c0.4-0.4,0.9-0.6,1.4-0.9c-0.5-0.5-1.3-0.7-2-0.7H7c-1.4,0-2.6,1.8-2.4,2.7v0.3
|
||||||
|
C5.1,29.8,6.8,33.5,8.5,35.7z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -271,6 +271,8 @@ Rectangle {
|
||||||
connectionsUserModel.getFirstPage();
|
connectionsUserModel.getFirstPage();
|
||||||
}
|
}
|
||||||
activeTab = "connectionsTab";
|
activeTab = "connectionsTab";
|
||||||
|
connectionsOnlineDot.visible = false;
|
||||||
|
pal.sendToScript({method: 'hideNotificationDot'});
|
||||||
connectionsHelpText.color = hifi.colors.blueAccent;
|
connectionsHelpText.color = hifi.colors.blueAccent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,6 +300,16 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: connectionsOnlineDot;
|
||||||
|
visible: false;
|
||||||
|
width: 10;
|
||||||
|
height: width;
|
||||||
|
radius: width;
|
||||||
|
color: "#EF3B4E"
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
}
|
||||||
// "CONNECTIONS" text
|
// "CONNECTIONS" text
|
||||||
RalewaySemiBold {
|
RalewaySemiBold {
|
||||||
id: connectionsTabSelectorText;
|
id: connectionsTabSelectorText;
|
||||||
|
@ -305,7 +317,11 @@ Rectangle {
|
||||||
// Text size
|
// Text size
|
||||||
size: hifi.fontSizes.tabularData;
|
size: hifi.fontSizes.tabularData;
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.fill: parent;
|
anchors.left: connectionsOnlineDot.visible ? connectionsOnlineDot.right : parent.left;
|
||||||
|
anchors.leftMargin: connectionsOnlineDot.visible ? 4 : 0;
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.bottom: parent.bottom;
|
||||||
|
anchors.right: parent.right;
|
||||||
// Style
|
// Style
|
||||||
font.capitalization: Font.AllUppercase;
|
font.capitalization: Font.AllUppercase;
|
||||||
color: activeTab === "connectionsTab" ? hifi.colors.blueAccent : hifi.colors.baseGray;
|
color: activeTab === "connectionsTab" ? hifi.colors.blueAccent : hifi.colors.baseGray;
|
||||||
|
@ -326,7 +342,7 @@ Rectangle {
|
||||||
anchors.left: connectionsTabSelectorTextContainer.left;
|
anchors.left: connectionsTabSelectorTextContainer.left;
|
||||||
anchors.top: connectionsTabSelectorTextContainer.top;
|
anchors.top: connectionsTabSelectorTextContainer.top;
|
||||||
anchors.topMargin: 1;
|
anchors.topMargin: 1;
|
||||||
anchors.leftMargin: connectionsTabSelectorTextMetrics.width + 42;
|
anchors.leftMargin: connectionsTabSelectorTextMetrics.width + 42 + connectionsOnlineDot.width + connectionsTabSelectorText.anchors.leftMargin;
|
||||||
RalewayRegular {
|
RalewayRegular {
|
||||||
id: connectionsHelpText;
|
id: connectionsHelpText;
|
||||||
text: "[?]";
|
text: "[?]";
|
||||||
|
@ -1267,6 +1283,9 @@ Rectangle {
|
||||||
case 'http.response':
|
case 'http.response':
|
||||||
http.handleHttpResponse(message);
|
http.handleHttpResponse(message);
|
||||||
break;
|
break;
|
||||||
|
case 'changeConnectionsDotStatus':
|
||||||
|
connectionsOnlineDot.visible = message.shouldShowDot;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Unrecognized message:', JSON.stringify(message));
|
console.log('Unrecognized message:', JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,9 +408,7 @@ Rectangle {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
onSendSignalToWallet: {
|
onSendSignalToWallet: {
|
||||||
if (msg.method === 'walletReset' || msg.method === 'passphraseReset') {
|
if (msg.method === 'walletSecurity_changeSecurityImage') {
|
||||||
sendToScript(msg);
|
|
||||||
} else if (msg.method === 'walletSecurity_changeSecurityImage') {
|
|
||||||
securityImageChange.initModel();
|
securityImageChange.initModel();
|
||||||
root.activeView = "securityImageChange";
|
root.activeView = "securityImageChange";
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,9 +382,8 @@ void ParabolaPointer::RenderState::ParabolaRenderItem::updateBounds() {
|
||||||
|
|
||||||
const gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabolaPipeline() {
|
const gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabolaPipeline() {
|
||||||
if (!_parabolaPipeline || !_transparentParabolaPipeline) {
|
if (!_parabolaPipeline || !_transparentParabolaPipeline) {
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::parabola);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::parabola);
|
||||||
auto state = std::make_shared<gpu::State>();
|
auto state = std::make_shared<gpu::State>();
|
||||||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||||
state->setBlendFunction(false,
|
state->setBlendFunction(false,
|
||||||
|
@ -396,6 +395,7 @@ const gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::get
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::parabola_translucent);
|
||||||
auto state = std::make_shared<gpu::State>();
|
auto state = std::make_shared<gpu::State>();
|
||||||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||||
state->setBlendFunction(true,
|
state->setBlendFunction(true,
|
||||||
|
|
|
@ -252,12 +252,6 @@ bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
||||||
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayID& overlayID, const PointerEvent& event) {
|
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayID& overlayID, const PointerEvent& event) {
|
||||||
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
||||||
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "Overlay ID:" << overlayID;
|
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);
|
emit contextOverlayClicked(_currentEntityWithContextOverlay);
|
||||||
_contextOverlayJustClicked = true;
|
_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) {
|
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
|
||||||
_selectionScriptingInterface->addToSelectedItemsList("contextOverlayHighlightList", "entity", entityItemID);
|
_selectionScriptingInterface->addToSelectedItemsList("contextOverlayHighlightList", "entity", entityItemID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,6 @@ private:
|
||||||
|
|
||||||
bool _isInMarketplaceInspectionMode { false };
|
bool _isInMarketplaceInspectionMode { false };
|
||||||
|
|
||||||
void openInspectionCertificate();
|
|
||||||
void openMarketplace();
|
|
||||||
void enableEntityHighlight(const EntityItemID& entityItemID);
|
void enableEntityHighlight(const EntityItemID& entityItemID);
|
||||||
void disableEntityHighlight(const EntityItemID& entityItemID);
|
void disableEntityHighlight(const EntityItemID& entityItemID);
|
||||||
|
|
||||||
|
|
|
@ -1322,6 +1322,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
emit DependencyManager::get<scriptable::ModelProviderFactory>()->
|
emit DependencyManager::get<scriptable::ModelProviderFactory>()->
|
||||||
modelRemovedFromScene(entity->getEntityItemID(), NestableType::Entity, _model);
|
modelRemovedFromScene(entity->getEntityItemID(), NestableType::Entity, _model);
|
||||||
}
|
}
|
||||||
|
setKey(false);
|
||||||
|
_didLastVisualGeometryRequestSucceed = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,6 +1349,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
if (_parsedModelURL != model->getURL()) {
|
if (_parsedModelURL != model->getURL()) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_texturesLoaded = false;
|
_texturesLoaded = false;
|
||||||
|
_jointMappingCompleted = false;
|
||||||
model->setURL(_parsedModelURL);
|
model->setURL(_parsedModelURL);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1457,7 +1460,6 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
mapJoints(entity, model->getJointNames());
|
mapJoints(entity, model->getJointNames());
|
||||||
//else the joint have been mapped before but we have a new animation to load
|
//else the joint have been mapped before but we have a new animation to load
|
||||||
} else if (_animation && (_animation->getURL().toString() != entity->getAnimationURL())) {
|
} else if (_animation && (_animation->getURL().toString() != entity->getAnimationURL())) {
|
||||||
_animation = DependencyManager::get<AnimationCache>()->getAnimation(entity->getAnimationURL());
|
|
||||||
_jointMappingCompleted = false;
|
_jointMappingCompleted = false;
|
||||||
mapJoints(entity, model->getJointNames());
|
mapJoints(entity, model->getJointNames());
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,12 +187,10 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
|
||||||
particle.basePosition = baseTransform.getTranslation();
|
particle.basePosition = baseTransform.getTranslation();
|
||||||
|
|
||||||
// Position, velocity, and acceleration
|
// Position, velocity, and acceleration
|
||||||
|
glm::vec3 emitDirection;
|
||||||
if (polarStart == 0.0f && polarFinish == 0.0f && emitDimensions.z == 0.0f) {
|
if (polarStart == 0.0f && polarFinish == 0.0f && emitDimensions.z == 0.0f) {
|
||||||
// Emit along z-axis from position
|
// Emit along z-axis from position
|
||||||
|
emitDirection = Vectors::UNIT_Z;
|
||||||
particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * Vectors::UNIT_Z);
|
|
||||||
particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Emit around point or from ellipsoid
|
// Emit around point or from ellipsoid
|
||||||
// - Distribute directions evenly around point
|
// - Distribute directions evenly around point
|
||||||
|
@ -210,7 +208,6 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
|
||||||
azimuth = azimuthStart + (TWO_PI + azimuthFinish - azimuthStart) * randFloat();
|
azimuth = azimuthStart + (TWO_PI + azimuthFinish - azimuthStart) * randFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 emitDirection;
|
|
||||||
if (emitDimensions == Vectors::ZERO) {
|
if (emitDimensions == Vectors::ZERO) {
|
||||||
// Point
|
// Point
|
||||||
emitDirection = glm::quat(glm::vec3(PI_OVER_TWO - elevation, 0.0f, azimuth)) * Vectors::UNIT_Z;
|
emitDirection = glm::quat(glm::vec3(PI_OVER_TWO - elevation, 0.0f, azimuth)) * Vectors::UNIT_Z;
|
||||||
|
@ -235,10 +232,10 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
|
||||||
));
|
));
|
||||||
particle.relativePosition += emitOrientation * emitPosition;
|
particle.relativePosition += emitOrientation * emitPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * emitDirection);
|
|
||||||
particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread;
|
|
||||||
}
|
}
|
||||||
|
particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * emitDirection);
|
||||||
|
particle.acceleration = emitAcceleration +
|
||||||
|
glm::vec3(randFloatInRange(-1.0f, 1.0f), randFloatInRange(-1.0f, 1.0f), randFloatInRange(-1.0f, 1.0f)) * accelerationSpread;
|
||||||
|
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,9 @@ EntityItemProperties ModelEntityItem::getProperties(EntityPropertyFlags desiredP
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslationsSet, getJointTranslationsSet);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslationsSet, getJointTranslationsSet);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslations, getJointTranslations);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslations, getJointTranslations);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(relayParentJoints, getRelayParentJoints);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(relayParentJoints, getRelayParentJoints);
|
||||||
|
withReadLock([&] {
|
||||||
_animationProperties.getProperties(properties);
|
_animationProperties.getProperties(properties);
|
||||||
|
});
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,15 +125,18 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
|
|
||||||
// grab a local copy of _animationProperties to avoid multiple locks
|
// grab a local copy of _animationProperties to avoid multiple locks
|
||||||
int bytesFromAnimation;
|
int bytesFromAnimation;
|
||||||
|
AnimationPropertyGroup animationProperties;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
AnimationPropertyGroup animationProperties = _animationProperties;
|
animationProperties = _animationProperties;
|
||||||
bytesFromAnimation = animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
bytesFromAnimation = animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
propertyFlags, overwriteLocalData, animationPropertiesChanged);
|
propertyFlags, overwriteLocalData, animationPropertiesChanged);
|
||||||
|
});
|
||||||
if (animationPropertiesChanged) {
|
if (animationPropertiesChanged) {
|
||||||
|
withWriteLock([&] {
|
||||||
applyNewAnimationProperties(animationProperties);
|
applyNewAnimationProperties(animationProperties);
|
||||||
|
});
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
bytesRead += bytesFromAnimation;
|
bytesRead += bytesFromAnimation;
|
||||||
dataAt += bytesFromAnimation;
|
dataAt += bytesFromAnimation;
|
||||||
|
@ -305,8 +310,10 @@ void ModelEntityItem::setAnimationURL(const QString& url) {
|
||||||
void ModelEntityItem::setAnimationSettings(const QString& value) {
|
void ModelEntityItem::setAnimationSettings(const QString& value) {
|
||||||
// NOTE: this method only called for old bitstream format
|
// NOTE: this method only called for old bitstream format
|
||||||
|
|
||||||
withWriteLock([&] {
|
AnimationPropertyGroup animationProperties;
|
||||||
auto animationProperties = _animationProperties;
|
withReadLock([&] {
|
||||||
|
animationProperties = _animationProperties;
|
||||||
|
});
|
||||||
|
|
||||||
// the animations setting is a JSON string that may contain various animation settings.
|
// the animations setting is a JSON string that may contain various animation settings.
|
||||||
// if it includes fps, currentFrame, or running, those values will be parsed out and
|
// if it includes fps, currentFrame, or running, those values will be parsed out and
|
||||||
|
@ -356,18 +363,24 @@ void ModelEntityItem::setAnimationSettings(const QString& value) {
|
||||||
bool allowTranslation = settingsMap["allowTranslation"].toBool();
|
bool allowTranslation = settingsMap["allowTranslation"].toBool();
|
||||||
animationProperties.setAllowTranslation(allowTranslation);
|
animationProperties.setAllowTranslation(allowTranslation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withWriteLock([&] {
|
||||||
applyNewAnimationProperties(animationProperties);
|
applyNewAnimationProperties(animationProperties);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setAnimationIsPlaying(bool value) {
|
void ModelEntityItem::setAnimationIsPlaying(bool value) {
|
||||||
_flags |= Simulation::DIRTY_UPDATEABLE;
|
_flags |= Simulation::DIRTY_UPDATEABLE;
|
||||||
|
withWriteLock([&] {
|
||||||
_animationProperties.setRunning(value);
|
_animationProperties.setRunning(value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setAnimationFPS(float value) {
|
void ModelEntityItem::setAnimationFPS(float value) {
|
||||||
_flags |= Simulation::DIRTY_UPDATEABLE;
|
_flags |= Simulation::DIRTY_UPDATEABLE;
|
||||||
|
withWriteLock([&] {
|
||||||
_animationProperties.setFPS(value);
|
_animationProperties.setFPS(value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
|
@ -557,11 +570,9 @@ void ModelEntityItem::setColor(const xColor& value) {
|
||||||
|
|
||||||
// Animation related items...
|
// Animation related items...
|
||||||
AnimationPropertyGroup ModelEntityItem::getAnimationProperties() const {
|
AnimationPropertyGroup ModelEntityItem::getAnimationProperties() const {
|
||||||
AnimationPropertyGroup result;
|
return resultWithReadLock<AnimationPropertyGroup>([&] {
|
||||||
withReadLock([&] {
|
return _animationProperties;
|
||||||
result = _animationProperties;
|
|
||||||
});
|
});
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelEntityItem::hasAnimation() const {
|
bool ModelEntityItem::hasAnimation() const {
|
||||||
|
@ -582,6 +593,18 @@ void ModelEntityItem::setAnimationCurrentFrame(float value) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelEntityItem::setAnimationAllowTranslation(bool value) {
|
||||||
|
withWriteLock([&] {
|
||||||
|
_animationProperties.setAllowTranslation(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelEntityItem::getAnimationAllowTranslation() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _animationProperties.getAllowTranslation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ModelEntityItem::setAnimationLoop(bool loop) {
|
void ModelEntityItem::setAnimationLoop(bool loop) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_animationProperties.setLoop(loop);
|
_animationProperties.setLoop(loop);
|
||||||
|
|
|
@ -88,8 +88,8 @@ public:
|
||||||
void setAnimationIsPlaying(bool value);
|
void setAnimationIsPlaying(bool value);
|
||||||
void setAnimationFPS(float value);
|
void setAnimationFPS(float value);
|
||||||
|
|
||||||
void setAnimationAllowTranslation(bool value) { _animationProperties.setAllowTranslation(value); };
|
void setAnimationAllowTranslation(bool value);
|
||||||
bool getAnimationAllowTranslation() const { return _animationProperties.getAllowTranslation(); };
|
bool getAnimationAllowTranslation() const;
|
||||||
|
|
||||||
void setAnimationLoop(bool loop);
|
void setAnimationLoop(bool loop);
|
||||||
bool getAnimationLoop() const;
|
bool getAnimationLoop() const;
|
||||||
|
|
18
libraries/render-utils/src/parabola_translucent.slf
Normal file
18
libraries/render-utils/src/parabola_translucent.slf
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 9/10/2018
|
||||||
|
// Copyright 2018 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
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
|
layout(location=0) in vec4 _color;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_FRESNEL, DEFAULT_ROUGHNESS);
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
VERTEX parabola
|
|
@ -11,6 +11,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
function AppUi(properties) {
|
function AppUi(properties) {
|
||||||
|
var request = Script.require('request').request;
|
||||||
/* Example development order:
|
/* Example development order:
|
||||||
1. var AppUi = Script.require('appUi');
|
1. var AppUi = Script.require('appUi');
|
||||||
2. Put appname-i.svg, appname-a.svg in graphicsDirectory (where non-default graphicsDirectory can be added in #3).
|
2. Put appname-i.svg, appname-a.svg in graphicsDirectory (where non-default graphicsDirectory can be added in #3).
|
||||||
|
@ -38,30 +39,56 @@ function AppUi(properties) {
|
||||||
that.tabletName = "com.highfidelity.interface.tablet.system";
|
that.tabletName = "com.highfidelity.interface.tablet.system";
|
||||||
that.inject = "";
|
that.inject = "";
|
||||||
that.graphicsDirectory = "icons/tablet-icons/"; // Where to look for button svgs. See below.
|
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.
|
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.setCurrentVisibleScreenMetadata = function setCurrentVisibleScreenMetadata(type, url) {
|
||||||
that.currentUrl = url;
|
that.currentVisibleScreenType = type;
|
||||||
that.type = /.qml$/.test(url) ? 'QML' : 'Web';
|
that.currentVisibleUrl = url;
|
||||||
}
|
};
|
||||||
that.open = function open(optionalUrl) { // How to open the app.
|
that.open = function open(optionalUrl, optionalInject) { // How to open the app.
|
||||||
var url = optionalUrl || that.home;
|
var url = optionalUrl || that.home;
|
||||||
that.setCurrentData(url);
|
var inject = optionalInject || that.inject;
|
||||||
if (that.isQML()) {
|
|
||||||
|
if (that.isQMLUrl(url)) {
|
||||||
that.tablet.loadQMLSource(url);
|
that.tablet.loadQMLSource(url);
|
||||||
} else {
|
} else {
|
||||||
that.tablet.gotoWebScreen(url, that.inject);
|
that.tablet.gotoWebScreen(url, inject);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 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 {
|
||||||
|
that.tablet.loadWebScreenOnTop(url, inject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
that.close = function close() { // How to close the app.
|
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.
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
that.tablet.gotoHomeScreen();
|
that.tablet.gotoHomeScreen();
|
||||||
};
|
};
|
||||||
that.buttonActive = function buttonActive(isActive) { // How to make the button active (white).
|
that.buttonActive = function buttonActive(isActive) { // How to make the button active (white).
|
||||||
that.button.editProperties({isActive: isActive});
|
that.button.editProperties({isActive: isActive});
|
||||||
};
|
};
|
||||||
|
that.isQMLUrl = function isQMLUrl(url) {
|
||||||
|
var type = /.qml$/.test(url) ? 'QML' : 'Web';
|
||||||
|
return type === 'QML';
|
||||||
|
};
|
||||||
|
that.isCurrentlyOnQMLScreen = function isCurrentlyOnQMLScreen() {
|
||||||
|
return that.currentVisibleScreenType === 'QML';
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// START Notification Handling Defaults
|
||||||
|
//
|
||||||
that.messagesWaiting = function messagesWaiting(isWaiting) { // How to indicate a message light on button.
|
that.messagesWaiting = function messagesWaiting(isWaiting) { // How to indicate a message light on button.
|
||||||
// Note that waitingButton doesn't have to exist unless someone explicitly calls this with isWaiting true.
|
// Note that waitingButton doesn't have to exist unless someone explicitly calls this with isWaiting true.
|
||||||
that.button.editProperties({
|
that.button.editProperties({
|
||||||
|
@ -69,16 +96,124 @@ function AppUi(properties) {
|
||||||
activeIcon: isWaiting ? that.activeMessagesButton : that.activeButton
|
activeIcon: isWaiting ? that.activeMessagesButton : that.activeButton
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
that.isQML = function isQML() { // We set type property in onClick.
|
that.notificationPollTimeout = false;
|
||||||
return that.type === 'QML';
|
that.notificationPollTimeoutMs = 60000;
|
||||||
|
that.notificationPollEndpoint = false;
|
||||||
|
that.notificationPollStopPaginatingConditionMet = false;
|
||||||
|
that.notificationDataProcessPage = function (data) {
|
||||||
|
return data;
|
||||||
};
|
};
|
||||||
that.eventSignal = function eventSignal() { // What signal to hook onMessage to.
|
that.notificationPollCallback = that.ignore;
|
||||||
return that.isQML() ? that.tablet.fromQml : that.tablet.webEventReceived;
|
that.notificationPollCaresAboutSince = false;
|
||||||
|
that.notificationInitialCallbackMade = false;
|
||||||
|
that.notificationDisplayBanner = function (message) {
|
||||||
|
Window.displayAnnouncement(message);
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// END Notification Handling Defaults
|
||||||
|
//
|
||||||
|
|
||||||
|
// 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:
|
// Overwrite with the given properties:
|
||||||
Object.keys(properties).forEach(function (key) { that[key] = properties[key]; });
|
Object.keys(properties).forEach(function (key) { that[key] = properties[key]; });
|
||||||
|
|
||||||
|
//
|
||||||
|
// START Notification Handling
|
||||||
|
//
|
||||||
|
var METAVERSE_BASE = Account.metaverseServerURL;
|
||||||
|
var currentDataPageToRetrieve = 1;
|
||||||
|
var concatenatedServerResponse = new Array();
|
||||||
|
that.notificationPoll = function () {
|
||||||
|
if (!that.notificationPollEndpoint) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// User is "appearing offline"
|
||||||
|
if (GlobalServices.findableBy === "none") {
|
||||||
|
that.notificationPollTimeout = Script.setTimeout(that.notificationPoll, that.notificationPollTimeoutMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = METAVERSE_BASE + that.notificationPollEndpoint;
|
||||||
|
|
||||||
|
if (that.notificationPollCaresAboutSince) {
|
||||||
|
url = url + "&since=" + (new Date().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
console.debug(that.buttonName, 'polling for notifications at endpoint', url);
|
||||||
|
|
||||||
|
function requestCallback(error, response) {
|
||||||
|
if (error || (response.status !== 'success')) {
|
||||||
|
print("Error: unable to get", url, error || response.status);
|
||||||
|
that.notificationPollTimeout = Script.setTimeout(that.notificationPoll, that.notificationPollTimeoutMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!that.notificationPollStopPaginatingConditionMet || that.notificationPollStopPaginatingConditionMet(response)) {
|
||||||
|
that.notificationPollTimeout = Script.setTimeout(that.notificationPoll, that.notificationPollTimeoutMs);
|
||||||
|
|
||||||
|
var notificationData;
|
||||||
|
if (concatenatedServerResponse.length) {
|
||||||
|
notificationData = concatenatedServerResponse;
|
||||||
|
} else {
|
||||||
|
notificationData = that.notificationDataProcessPage(response);
|
||||||
|
}
|
||||||
|
console.debug(that.buttonName, 'notification data for processing:', JSON.stringify(notificationData));
|
||||||
|
that.notificationPollCallback(notificationData);
|
||||||
|
that.notificationInitialCallbackMade = true;
|
||||||
|
currentDataPageToRetrieve = 1;
|
||||||
|
concatenatedServerResponse = new Array();
|
||||||
|
} else {
|
||||||
|
concatenatedServerResponse = concatenatedServerResponse.concat(that.notificationDataProcessPage(response));
|
||||||
|
currentDataPageToRetrieve++;
|
||||||
|
request({ uri: (url + "&page=" + currentDataPageToRetrieve) }, requestCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request({ uri: url }, requestCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
// This won't do anything if there isn't a notification endpoint set
|
||||||
|
that.notificationPoll();
|
||||||
|
|
||||||
|
function availabilityChanged() {
|
||||||
|
if (that.notificationPollTimeout) {
|
||||||
|
Script.clearTimeout(that.notificationPollTimeout);
|
||||||
|
that.notificationPollTimeout = false;
|
||||||
|
}
|
||||||
|
that.notificationPoll();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// END Notification Handling
|
||||||
|
//
|
||||||
|
|
||||||
// Properties:
|
// Properties:
|
||||||
that.tablet = Tablet.getTablet(that.tabletName);
|
that.tablet = Tablet.getTablet(that.tabletName);
|
||||||
// Must be after we gather properties.
|
// Must be after we gather properties.
|
||||||
|
@ -100,65 +235,58 @@ function AppUi(properties) {
|
||||||
}
|
}
|
||||||
that.button = that.tablet.addButton(buttonOptions);
|
that.button = that.tablet.addButton(buttonOptions);
|
||||||
that.ignore = function ignore() { };
|
that.ignore = function ignore() { };
|
||||||
|
that.hasOutboundEventBridge = false;
|
||||||
// Handlers
|
that.hasInboundQmlEventBridge = false;
|
||||||
that.onScreenChanged = function onScreenChanged(type, url) {
|
that.hasInboundHtmlEventBridge = false;
|
||||||
// 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;
|
|
||||||
// HTML event bridge uses strings, not objects. Here we abstract over that.
|
// HTML event bridge uses strings, not objects. Here we abstract over that.
|
||||||
// (Although injected javascript still has to use JSON.stringify/JSON.parse.)
|
// (Although injected javascript still has to use JSON.stringify/JSON.parse.)
|
||||||
that.sendToHtml = function (messageObject) { that.tablet.emitScriptEvent(JSON.stringify(messageObject)); };
|
that.sendToHtml = function (messageObject) {
|
||||||
that.fromHtml = function (messageString) { that.onMessage(JSON.parse(messageString)); };
|
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.sendMessage = that.ignore;
|
||||||
that.wireEventBridge = function wireEventBridge(on) {
|
that.wireEventBridge = function wireEventBridge(on) {
|
||||||
// Uniquivocally sets that.sendMessage(messageObject) to do the right thing.
|
// Uniquivocally sets that.sendMessage(messageObject) to do the right thing.
|
||||||
// Sets hasEventBridge and wires onMessage to eventSignal as appropriate, IFF onMessage defined.
|
// Sets has*EventBridge and wires onMessage to the proper event bridge as appropriate, IFF onMessage defined.
|
||||||
var handler, isQml = that.isQML();
|
var isCurrentlyOnQMLScreen = that.isCurrentlyOnQMLScreen();
|
||||||
// Outbound (always, regardless of whether there is an inbound handler).
|
// Outbound (always, regardless of whether there is an inbound handler).
|
||||||
if (on) {
|
if (on) {
|
||||||
that.sendMessage = isQml ? that.tablet.sendToQml : that.sendToHtml;
|
that.sendMessage = isCurrentlyOnQMLScreen ? that.tablet.sendToQml : that.sendToHtml;
|
||||||
|
that.hasOutboundEventBridge = true;
|
||||||
} else {
|
} else {
|
||||||
that.sendMessage = that.ignore;
|
that.sendMessage = that.ignore;
|
||||||
|
that.hasOutboundEventBridge = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!that.onMessage) { return; }
|
if (!that.onMessage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Inbound
|
// Inbound
|
||||||
handler = isQml ? that.onMessage : that.fromHtml;
|
|
||||||
if (on) {
|
if (on) {
|
||||||
if (!that.hasEventBridge) {
|
if (isCurrentlyOnQMLScreen && !that.hasInboundQmlEventBridge) {
|
||||||
console.debug(that.buttonName, 'connecting', that.eventSignal());
|
console.debug(that.buttonName, 'connecting', that.tablet.fromQml);
|
||||||
that.eventSignal().connect(handler);
|
that.tablet.fromQml.connect(that.onMessage);
|
||||||
that.hasEventBridge = true;
|
that.hasInboundQmlEventBridge = true;
|
||||||
|
} else if (!isCurrentlyOnQMLScreen && !that.hasInboundHtmlEventBridge) {
|
||||||
|
console.debug(that.buttonName, 'connecting', that.tablet.webEventReceived);
|
||||||
|
that.tablet.webEventReceived.connect(that.fromHtml);
|
||||||
|
that.hasInboundHtmlEventBridge = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (that.hasEventBridge) {
|
if (that.hasInboundQmlEventBridge) {
|
||||||
console.debug(that.buttonName, 'disconnecting', that.eventSignal());
|
console.debug(that.buttonName, 'disconnecting', that.tablet.fromQml);
|
||||||
that.eventSignal().disconnect(handler);
|
that.tablet.fromQml.disconnect(that.onMessage);
|
||||||
that.hasEventBridge = false;
|
that.hasInboundQmlEventBridge = false;
|
||||||
|
}
|
||||||
|
if (that.hasInboundHtmlEventBridge) {
|
||||||
|
console.debug(that.buttonName, 'disconnecting', that.tablet.webEventReceived);
|
||||||
|
that.tablet.webEventReceived.disconnect(that.fromHtml);
|
||||||
|
that.hasInboundHtmlEventBridge = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -175,6 +303,7 @@ function AppUi(properties) {
|
||||||
} : that.ignore;
|
} : that.ignore;
|
||||||
that.onScriptEnding = function onScriptEnding() {
|
that.onScriptEnding = function onScriptEnding() {
|
||||||
// Close if necessary, clean up any remaining handlers, and remove the button.
|
// Close if necessary, clean up any remaining handlers, and remove the button.
|
||||||
|
GlobalServices.findableByChanged.disconnect(availabilityChanged);
|
||||||
if (that.isOpen) {
|
if (that.isOpen) {
|
||||||
that.close();
|
that.close();
|
||||||
}
|
}
|
||||||
|
@ -185,10 +314,15 @@ function AppUi(properties) {
|
||||||
}
|
}
|
||||||
that.tablet.removeButton(that.button);
|
that.tablet.removeButton(that.button);
|
||||||
}
|
}
|
||||||
|
if (that.notificationPollTimeout) {
|
||||||
|
Script.clearInterval(that.notificationPollTimeout);
|
||||||
|
that.notificationPollTimeout = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// Set up the handlers.
|
// Set up the handlers.
|
||||||
that.tablet.screenChanged.connect(that.onScreenChanged);
|
that.tablet.screenChanged.connect(that.onScreenChanged);
|
||||||
that.button.clicked.connect(that.onClicked);
|
that.button.clicked.connect(that.onClicked);
|
||||||
Script.scriptEnding.connect(that.onScriptEnding);
|
Script.scriptEnding.connect(that.onScriptEnding);
|
||||||
|
GlobalServices.findableByChanged.connect(availabilityChanged);
|
||||||
}
|
}
|
||||||
module.exports = AppUi;
|
module.exports = AppUi;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
Script.include("/~/system/libraries/accountUtils.js");
|
Script.include("/~/system/libraries/accountUtils.js");
|
||||||
Script.include("/~/system/libraries/connectionUtils.js");
|
Script.include("/~/system/libraries/connectionUtils.js");
|
||||||
|
var AppUi = Script.require('appUi');
|
||||||
|
|
||||||
var MARKETPLACE_URL = Account.metaverseServerURL + "/marketplace";
|
var MARKETPLACE_URL = Account.metaverseServerURL + "/marketplace";
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@
|
||||||
method: 'updateSelectedRecipientUsername',
|
method: 'updateSelectedRecipientUsername',
|
||||||
userName: username === "" ? "unknown username" : username
|
userName: username === "" ? "unknown username" : username
|
||||||
};
|
};
|
||||||
sendToQml(message);
|
ui.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleClick(pickRay) {
|
function handleClick(pickRay) {
|
||||||
|
@ -208,7 +209,7 @@
|
||||||
displayName: '"' + AvatarList.getAvatar(avatarId).sessionDisplayName + '"',
|
displayName: '"' + AvatarList.getAvatar(avatarId).sessionDisplayName + '"',
|
||||||
userName: ''
|
userName: ''
|
||||||
};
|
};
|
||||||
sendToQml(message);
|
ui.sendMessage(message);
|
||||||
|
|
||||||
ExtendedOverlay.some(function (overlay) {
|
ExtendedOverlay.some(function (overlay) {
|
||||||
var id = overlay.key;
|
var id = overlay.key;
|
||||||
|
@ -299,39 +300,6 @@
|
||||||
triggerPressMapping.from(Controller.Standard.LT).peek().to(makePressHandler(Controller.Standard.LeftHand));
|
triggerPressMapping.from(Controller.Standard.LT).peek().to(makePressHandler(Controller.Standard.LeftHand));
|
||||||
// END AVATAR SELECTOR LOGIC
|
// END AVATAR SELECTOR LOGIC
|
||||||
|
|
||||||
// Function Name: onButtonClicked()
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
// -Fired when the app button is pressed.
|
|
||||||
//
|
|
||||||
// Relevant Variables:
|
|
||||||
// -WALLET_QML_SOURCE: The path to the Wallet QML
|
|
||||||
// -onWalletScreen: true/false depending on whether we're looking at the app.
|
|
||||||
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
|
||||||
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
|
||||||
var onWalletScreen = false;
|
|
||||||
function onButtonClicked() {
|
|
||||||
if (!tablet) {
|
|
||||||
print("Warning in buttonClicked(): 'tablet' undefined!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (onWalletScreen) {
|
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
tablet.loadQMLSource(WALLET_QML_SOURCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function Name: sendToQml()
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
// -Use this function to send a message to the QML (i.e. to change appearances). The "message" argument is what is sent to
|
|
||||||
// the QML in the format "{method, params}", like json-rpc. See also fromQml().
|
|
||||||
function sendToQml(message) {
|
|
||||||
tablet.sendToQml(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var sendMoneyRecipient;
|
var sendMoneyRecipient;
|
||||||
var sendMoneyParticleEffectUpdateTimer;
|
var sendMoneyParticleEffectUpdateTimer;
|
||||||
var particleEffectTimestamp;
|
var particleEffectTimestamp;
|
||||||
|
@ -373,9 +341,10 @@
|
||||||
type: 'ParticleEffect'
|
type: 'ParticleEffect'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var MS_PER_SEC = 1000;
|
||||||
function updateSendMoneyParticleEffect() {
|
function updateSendMoneyParticleEffect() {
|
||||||
var timestampNow = Date.now();
|
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();
|
deleteSendMoneyParticleEffect();
|
||||||
return;
|
return;
|
||||||
} else if ((timestampNow - particleEffectTimestamp) > SEND_MONEY_PARTICLE_EMITTING_DURATION) {
|
} else if ((timestampNow - particleEffectTimestamp) > SEND_MONEY_PARTICLE_EMITTING_DURATION) {
|
||||||
|
@ -418,29 +387,28 @@
|
||||||
// Description:
|
// Description:
|
||||||
// -Called when a message is received from SpectatorCamera.qml. The "message" argument is what is sent from the QML
|
// -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().
|
// 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");
|
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
||||||
|
|
||||||
function fromQml(message) {
|
function fromQml(message) {
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'passphrasePopup_cancelClicked':
|
case 'passphrasePopup_cancelClicked':
|
||||||
case 'needsLogIn_cancelClicked':
|
case 'needsLogIn_cancelClicked':
|
||||||
tablet.gotoHomeScreen();
|
ui.close();
|
||||||
break;
|
break;
|
||||||
case 'walletSetup_cancelClicked':
|
case 'walletSetup_cancelClicked':
|
||||||
switch (message.referrer) {
|
switch (message.referrer) {
|
||||||
case '': // User clicked "Wallet" app
|
case '': // User clicked "Wallet" app
|
||||||
case undefined:
|
case undefined:
|
||||||
case null:
|
case null:
|
||||||
tablet.gotoHomeScreen();
|
ui.close();
|
||||||
break;
|
break;
|
||||||
case 'purchases':
|
case 'purchases':
|
||||||
case 'marketplace cta':
|
case 'marketplace cta':
|
||||||
case 'mainPage':
|
case 'mainPage':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
default: // User needs to return to an individual marketplace item URL
|
default: // User needs to return to an individual marketplace item URL
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.referrer, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL + '/items/' + message.referrer, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -451,27 +419,18 @@
|
||||||
break; // do nothing here, handled in marketplaces.js
|
break; // do nothing here, handled in marketplaces.js
|
||||||
case 'maybeEnableHmdPreview':
|
case 'maybeEnableHmdPreview':
|
||||||
break; // do nothing here, handled in marketplaces.js
|
break; // do nothing here, handled in marketplaces.js
|
||||||
case 'passphraseReset':
|
|
||||||
onButtonClicked();
|
|
||||||
onButtonClicked();
|
|
||||||
break;
|
|
||||||
case 'walletReset':
|
|
||||||
Settings.setValue("isFirstUseOfPurchases", true);
|
|
||||||
onButtonClicked();
|
|
||||||
onButtonClicked();
|
|
||||||
break;
|
|
||||||
case 'transactionHistory_linkClicked':
|
case 'transactionHistory_linkClicked':
|
||||||
tablet.gotoWebScreen(message.marketplaceLink, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(message.marketplaceLink, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'goToPurchases_fromWalletHome':
|
case 'goToPurchases_fromWalletHome':
|
||||||
case 'goToPurchases':
|
case 'goToPurchases':
|
||||||
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
break;
|
break;
|
||||||
case 'goToMarketplaceMainPage':
|
case 'goToMarketplaceMainPage':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'goToMarketplaceItemPage':
|
case 'goToMarketplaceItemPage':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'refreshConnections':
|
case 'refreshConnections':
|
||||||
print('Refreshing Connections...');
|
print('Refreshing Connections...');
|
||||||
|
@ -526,93 +485,43 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function Name: wireEventBridge()
|
function walletOpened() {
|
||||||
//
|
|
||||||
// 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 wireEventBridge(on) {
|
|
||||||
if (!tablet) {
|
|
||||||
print("Warning in wireEventBridge(): 'tablet' undefined!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (on) {
|
|
||||||
if (!hasEventBridge) {
|
|
||||||
tablet.fromQml.connect(fromQml);
|
|
||||||
hasEventBridge = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (hasEventBridge) {
|
|
||||||
tablet.fromQml.disconnect(fromQml);
|
|
||||||
hasEventBridge = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function Name: onTabletScreenChanged()
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
|
|
||||||
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
|
|
||||||
function onTabletScreenChanged(type, url) {
|
|
||||||
onWalletScreen = (type === "QML" && url === WALLET_QML_SOURCE);
|
|
||||||
wireEventBridge(onWalletScreen);
|
|
||||||
// Change button to active when window is first openend, false otherwise.
|
|
||||||
if (button) {
|
|
||||||
button.editProperties({ isActive: onWalletScreen });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onWalletScreen) {
|
|
||||||
if (!isWired) {
|
|
||||||
Users.usernameFromIDReply.connect(usernameFromIDReply);
|
Users.usernameFromIDReply.connect(usernameFromIDReply);
|
||||||
Controller.mousePressEvent.connect(handleMouseEvent);
|
Controller.mousePressEvent.connect(handleMouseEvent);
|
||||||
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
|
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
|
||||||
triggerMapping.enable();
|
triggerMapping.enable();
|
||||||
triggerPressMapping.enable();
|
triggerPressMapping.enable();
|
||||||
}
|
}
|
||||||
isWired = true;
|
|
||||||
} else {
|
function walletClosed() {
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Manage the connection between the button and the window.
|
// Manage the connection between the button and the window.
|
||||||
//
|
//
|
||||||
var button;
|
var BUTTON_NAME = "WALLET";
|
||||||
var buttonName = "WALLET";
|
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
||||||
var tablet = null;
|
var ui;
|
||||||
var walletEnabled = Settings.getValue("commerce", true);
|
|
||||||
function startup() {
|
function startup() {
|
||||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
ui = new AppUi({
|
||||||
if (walletEnabled) {
|
buttonName: BUTTON_NAME,
|
||||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
sortOrder: 10,
|
||||||
button = tablet.addButton({
|
home: WALLET_QML_SOURCE,
|
||||||
text: buttonName,
|
onOpened: walletOpened,
|
||||||
icon: "icons/tablet-icons/wallet-i.svg",
|
onClosed: walletClosed,
|
||||||
activeIcon: "icons/tablet-icons/wallet-a.svg",
|
onMessage: fromQml
|
||||||
sortOrder: 10
|
|
||||||
});
|
});
|
||||||
button.clicked.connect(onButtonClicked);
|
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
var isWired = false;
|
|
||||||
var isUpdateOverlaysWired = false;
|
var isUpdateOverlaysWired = false;
|
||||||
function off() {
|
function off() {
|
||||||
if (isWired) {
|
|
||||||
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
|
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
|
||||||
Controller.mousePressEvent.disconnect(handleMouseEvent);
|
Controller.mousePressEvent.disconnect(handleMouseEvent);
|
||||||
Controller.mouseMoveEvent.disconnect(handleMouseMoveEvent);
|
Controller.mouseMoveEvent.disconnect(handleMouseMoveEvent);
|
||||||
triggerMapping.disable();
|
triggerMapping.disable();
|
||||||
triggerPressMapping.disable();
|
triggerPressMapping.disable();
|
||||||
|
|
||||||
isWired = false;
|
|
||||||
}
|
|
||||||
if (isUpdateOverlaysWired) {
|
if (isUpdateOverlaysWired) {
|
||||||
Script.update.disconnect(updateOverlays);
|
Script.update.disconnect(updateOverlays);
|
||||||
isUpdateOverlaysWired = false;
|
isUpdateOverlaysWired = false;
|
||||||
|
@ -621,15 +530,7 @@
|
||||||
}
|
}
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||||
button.clicked.disconnect(onButtonClicked);
|
|
||||||
tablet.removeButton(button);
|
|
||||||
deleteSendMoneyParticleEffect();
|
deleteSendMoneyParticleEffect();
|
||||||
if (tablet) {
|
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
|
||||||
if (onWalletScreen) {
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,5 +539,4 @@
|
||||||
//
|
//
|
||||||
startup();
|
startup();
|
||||||
Script.scriptEnding.connect(shutdown);
|
Script.scriptEnding.connect(shutdown);
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
//
|
//
|
||||||
// help.js
|
// help.js
|
||||||
// scripts/system/
|
// scripts/system/
|
||||||
|
@ -13,49 +13,17 @@
|
||||||
/* globals Tablet, Script, HMD, Controller, Menu */
|
/* globals Tablet, Script, HMD, Controller, Menu */
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
var AppUi = Script.require('appUi');
|
||||||
|
|
||||||
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
|
||||||
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
||||||
var buttonName = "HELP";
|
var HELP_BUTTON_NAME = "HELP";
|
||||||
var onHelpScreen = false;
|
var ui;
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
function startup() {
|
||||||
var button = tablet.addButton({
|
ui = new AppUi({
|
||||||
icon: "icons/tablet-icons/help-i.svg",
|
buttonName: HELP_BUTTON_NAME,
|
||||||
activeIcon: "icons/tablet-icons/help-a.svg",
|
sortOrder: 6,
|
||||||
text: buttonName,
|
home: HELP_URL
|
||||||
sortOrder: 6
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var enabled = false;
|
|
||||||
function onClicked() {
|
|
||||||
if (onHelpScreen) {
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
if (HMD.tabletID) {
|
|
||||||
Entities.editEntity(HMD.tabletID, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
|
||||||
}
|
}
|
||||||
Menu.triggerOption('Help...');
|
startup();
|
||||||
onHelpScreen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
|
||||||
onHelpScreen = type === "Web" && (url.indexOf(HELP_URL) === 0);
|
|
||||||
button.editProperties({ isActive: onHelpScreen });
|
|
||||||
}
|
|
||||||
|
|
||||||
button.clicked.connect(onClicked);
|
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
|
||||||
if (onHelpScreen) {
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
}
|
|
||||||
button.clicked.disconnect(onClicked);
|
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
|
||||||
if (tablet) {
|
|
||||||
tablet.removeButton(button);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global $, window, MutationObserver */
|
||||||
|
|
||||||
//
|
//
|
||||||
// marketplacesInject.js
|
// marketplacesInject.js
|
||||||
//
|
//
|
||||||
|
@ -11,7 +13,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
// Event bridge messages.
|
// Event bridge messages.
|
||||||
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||||
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
var messagesWaiting = false;
|
var messagesWaiting = false;
|
||||||
|
|
||||||
function injectCommonCode(isDirectoryPage) {
|
function injectCommonCode(isDirectoryPage) {
|
||||||
|
|
||||||
// Supporting styles from marketplaces.css.
|
// Supporting styles from marketplaces.css.
|
||||||
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
||||||
$("head").append(
|
$("head").append(
|
||||||
|
@ -74,7 +74,9 @@
|
||||||
(document.referrer !== "") ? window.history.back() : window.location = (marketplaceBaseURL + "/marketplace?");
|
(document.referrer !== "") ? window.history.back() : window.location = (marketplaceBaseURL + "/marketplace?");
|
||||||
});
|
});
|
||||||
$("#all-markets").on("click", function () {
|
$("#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({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "WALLET_SETUP"
|
type: "WALLET_SETUP"
|
||||||
}));
|
}));
|
||||||
}
|
};
|
||||||
|
|
||||||
function maybeAddSetupWalletButton() {
|
function maybeAddSetupWalletButton() {
|
||||||
if (!$('body').hasClass("walletsetup-injected") && userIsLoggedIn && walletNeedsSetup) {
|
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').prev().attr("class", 'col-xs-6');
|
||||||
$(this).closest('.col-xs-3').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({
|
priceElement.css({
|
||||||
"padding": "3px 5px",
|
"padding": "3px 5px",
|
||||||
"height": "40px",
|
"height": "40px",
|
||||||
|
@ -355,12 +357,12 @@
|
||||||
function injectAddScrollbarToCategories() {
|
function injectAddScrollbarToCategories() {
|
||||||
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
||||||
$('body > div.container').css('display', 'none')
|
$('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 () {
|
$('#categories-dropdown').on('hide.bs.dropdown', function () {
|
||||||
$('body > div.container').css('display', '')
|
$('body > div.container').css('display', '');
|
||||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' })
|
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +384,6 @@
|
||||||
mutations.forEach(function (mutation) {
|
mutations.forEach(function (mutation) {
|
||||||
injectBuyButtonOnMainPage();
|
injectBuyButtonOnMainPage();
|
||||||
});
|
});
|
||||||
//observer.disconnect();
|
|
||||||
});
|
});
|
||||||
var config = { attributes: true, childList: true, characterData: true };
|
var config = { attributes: true, childList: true, characterData: true };
|
||||||
observer.observe(target, config);
|
observer.observe(target, config);
|
||||||
|
@ -503,10 +504,11 @@
|
||||||
$(".top-title .col-sm-4").append(downloadContainer);
|
$(".top-title .col-sm-4").append(downloadContainer);
|
||||||
downloadContainer.append(downloadFBX);
|
downloadContainer.append(downloadFBX);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Automatic download to High Fidelity.
|
// Automatic download to High Fidelity.
|
||||||
function startAutoDownload() {
|
function startAutoDownload() {
|
||||||
|
|
||||||
// One file request at a time.
|
// One file request at a time.
|
||||||
if (isPreparing) {
|
if (isPreparing) {
|
||||||
console.log("WARNING: Clara.io FBX: Prepare only one download at a time");
|
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.
|
// User must be able to write to Asset Server.
|
||||||
if (!canWriteAssets) {
|
if (!canWriteAssets) {
|
||||||
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +583,10 @@
|
||||||
|
|
||||||
if (statusMessage !== "") {
|
if (statusMessage !== "") {
|
||||||
// Update the UI with the most recent status message.
|
// 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) {
|
if (this.status !== HTTP_OK) {
|
||||||
statusMessage = "Zip file request terminated with " + this.status + " " + this.statusText;
|
statusMessage = "Zip file request terminated with " + this.status + " " + this.statusText;
|
||||||
console.log("ERROR: Clara.io FBX: " + statusMessage);
|
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") {
|
} else if (zipFileURL.slice(-4) !== ".zip") {
|
||||||
statusMessage = "Error creating zip file for download.";
|
statusMessage = "Error creating zip file for download.";
|
||||||
console.log("ERROR: Clara.io FBX: " + statusMessage + ": " + zipFileURL);
|
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 {
|
} 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);
|
console.log("Clara.io FBX: File download initiated for " + zipFileURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,14 +632,15 @@
|
||||||
isPreparing = true;
|
isPreparing = true;
|
||||||
|
|
||||||
console.log("Clara.io FBX: Request zip file for " + uuid);
|
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.open("POST", url, true);
|
||||||
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
||||||
xmlHttpRequest.send();
|
xmlHttpRequest.send();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function injectClaraCode() {
|
function injectClaraCode() {
|
||||||
|
|
||||||
|
@ -663,7 +679,9 @@
|
||||||
updateClaraCodeInterval = undefined;
|
updateClaraCodeInterval = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
EventBridge.emitWebEvent(QUERY_CAN_WRITE_ASSETS);
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: QUERY_CAN_WRITE_ASSETS
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelClaraDownload() {
|
function cancelClaraDownload() {
|
||||||
|
@ -673,7 +691,9 @@
|
||||||
xmlHttpRequest.abort();
|
xmlHttpRequest.abort();
|
||||||
xmlHttpRequest = null;
|
xmlHttpRequest = null;
|
||||||
console.log("Clara.io FBX: File download cancelled");
|
console.log("Clara.io FBX: File download cancelled");
|
||||||
EventBridge.emitWebEvent(CLARA_IO_CANCELLED_DOWNLOAD);
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_CANCELLED_DOWNLOAD
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,27 +728,24 @@
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
EventBridge.scriptEventReceived.connect(function (message) {
|
EventBridge.scriptEventReceived.connect(function (message) {
|
||||||
if (message.slice(0, CAN_WRITE_ASSETS.length) === CAN_WRITE_ASSETS) {
|
message = JSON.parse(message);
|
||||||
canWriteAssets = message.slice(-4) === "true";
|
if (message.type === CAN_WRITE_ASSETS) {
|
||||||
} else if (message.slice(0, CLARA_IO_CANCEL_DOWNLOAD.length) === CLARA_IO_CANCEL_DOWNLOAD) {
|
canWriteAssets = message.canWriteAssets;
|
||||||
|
} else if (message.type === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||||
cancelClaraDownload();
|
cancelClaraDownload();
|
||||||
} else {
|
} else if (message.type === "marketplaces") {
|
||||||
var parsedJsonMessage = JSON.parse(message);
|
if (message.action === "commerceSetting") {
|
||||||
|
commerceMode = !!message.data.commerceMode;
|
||||||
if (parsedJsonMessage.type === "marketplaces") {
|
userIsLoggedIn = !!message.data.userIsLoggedIn;
|
||||||
if (parsedJsonMessage.action === "commerceSetting") {
|
walletNeedsSetup = !!message.data.walletNeedsSetup;
|
||||||
commerceMode = !!parsedJsonMessage.data.commerceMode;
|
marketplaceBaseURL = message.data.metaverseServerURL;
|
||||||
userIsLoggedIn = !!parsedJsonMessage.data.userIsLoggedIn;
|
|
||||||
walletNeedsSetup = !!parsedJsonMessage.data.walletNeedsSetup;
|
|
||||||
marketplaceBaseURL = parsedJsonMessage.data.metaverseServerURL;
|
|
||||||
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
||||||
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
||||||
}
|
}
|
||||||
messagesWaiting = parsedJsonMessage.data.messagesWaiting;
|
messagesWaiting = message.data.messagesWaiting;
|
||||||
injectCode();
|
injectCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Request commerce setting
|
// Request commerce setting
|
||||||
|
|
|
@ -16,25 +16,19 @@
|
||||||
var selectionDisplay = null; // for gridTool.js to ignore
|
var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
var AppUi = Script.require('appUi');
|
||||||
Script.include("/~/system/libraries/WebTablet.js");
|
|
||||||
Script.include("/~/system/libraries/gridTool.js");
|
Script.include("/~/system/libraries/gridTool.js");
|
||||||
Script.include("/~/system/libraries/connectionUtils.js");
|
Script.include("/~/system/libraries/connectionUtils.js");
|
||||||
|
|
||||||
var METAVERSE_SERVER_URL = Account.metaverseServerURL;
|
var METAVERSE_SERVER_URL = Account.metaverseServerURL;
|
||||||
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 MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
||||||
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
||||||
var MARKETPLACE_CHECKOUT_QML_PATH = "hifi/commerce/checkout/Checkout.qml";
|
var MARKETPLACE_CHECKOUT_QML_PATH = "hifi/commerce/checkout/Checkout.qml";
|
||||||
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
||||||
var MARKETPLACE_WALLET_QML_PATH = "hifi/commerce/wallet/Wallet.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"));
|
var REZZING_SOUND = SoundCache.getSound(Script.resolvePath("../assets/sounds/rezzing.wav"));
|
||||||
|
|
||||||
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
|
||||||
// var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
|
||||||
|
|
||||||
// Event bridge messages.
|
// Event bridge messages.
|
||||||
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||||
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
||||||
|
@ -58,45 +52,17 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
if (id === messageBox && button === CANCEL_BUTTON) {
|
if (id === messageBox && button === CANCEL_BUTTON) {
|
||||||
isDownloadBeingCancelled = true;
|
isDownloadBeingCancelled = true;
|
||||||
messageBox = null;
|
messageBox = null;
|
||||||
tablet.emitScriptEvent(CLARA_IO_CANCEL_DOWNLOAD);
|
ui.sendToHtml({
|
||||||
}
|
type: CLARA_IO_CANCEL_DOWNLOAD
|
||||||
}
|
|
||||||
|
|
||||||
var onMarketplaceScreen = false;
|
|
||||||
var onCommerceScreen = false;
|
|
||||||
|
|
||||||
var debugCheckout = false;
|
|
||||||
var debugError = false;
|
|
||||||
function showMarketplace() {
|
|
||||||
if (!debugCheckout) {
|
|
||||||
UserActivityLogger.openedMarketplace();
|
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
|
||||||
} else {
|
|
||||||
tablet.pushOntoStack(MARKETPLACE_CHECKOUT_QML_PATH);
|
|
||||||
sendToQml({
|
|
||||||
method: 'updateCheckoutQML', params: {
|
|
||||||
itemId: '424611a2-73d0-4c03-9087-26a6a279257b',
|
|
||||||
itemName: '2018-02-15 Finnegon',
|
|
||||||
itemPrice: (debugError ? 10 : 3),
|
|
||||||
itemHref: 'http://devmpassets.highfidelity.com/424611a2-73d0-4c03-9087-26a6a279257b-v1/finnigon.fst',
|
|
||||||
categories: ["Miscellaneous"]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function messagesWaiting(isWaiting) {
|
|
||||||
if (marketplaceButton) {
|
|
||||||
marketplaceButton.editProperties({
|
|
||||||
icon: (isWaiting ? WAITING_ICON : NORMAL_ICON),
|
|
||||||
activeIcon: (isWaiting ? WAITING_ACTIVE : NORMAL_ACTIVE)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanWriteAssetsChanged() {
|
function onCanWriteAssetsChanged() {
|
||||||
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
ui.sendToHtml({
|
||||||
tablet.emitScriptEvent(message);
|
type: CAN_WRITE_ASSETS,
|
||||||
|
canWriteAssets: Entities.canWriteAssets()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,13 +85,46 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
function openWallet() {
|
function openWallet() {
|
||||||
tablet.pushOntoStack(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) {
|
function setCertificateInfo(currentEntityWithContextOverlay, itemCertificateId) {
|
||||||
wireEventBridge(true);
|
var certificateId = itemCertificateId ||
|
||||||
var certificateId = itemCertificateId || (Entities.getEntityProperties(currentEntityWithContextOverlay, ['certificateID']).certificateID);
|
(Entities.getEntityProperties(currentEntityWithContextOverlay, ['certificateID']).certificateID);
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'inspectionCertificate_setCertificateId',
|
method: 'inspectionCertificate_setCertificateId',
|
||||||
entityId: currentEntityWithContextOverlay,
|
entityId: currentEntityWithContextOverlay,
|
||||||
certificateId: certificateId
|
certificateId: certificateId
|
||||||
|
@ -134,13 +133,13 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
|
|
||||||
function onUsernameChanged() {
|
function onUsernameChanged() {
|
||||||
if (onMarketplaceScreen) {
|
if (onMarketplaceScreen) {
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var userHasUpdates = false;
|
var userHasUpdates = false;
|
||||||
function sendCommerceSettings() {
|
function sendCommerceSettings() {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendToHtml({
|
||||||
type: "marketplaces",
|
type: "marketplaces",
|
||||||
action: "commerceSetting",
|
action: "commerceSetting",
|
||||||
data: {
|
data: {
|
||||||
|
@ -150,7 +149,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
metaverseServerURL: Account.metaverseServerURL,
|
metaverseServerURL: Account.metaverseServerURL,
|
||||||
messagesWaiting: userHasUpdates
|
messagesWaiting: userHasUpdates
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// BEGIN AVATAR SELECTOR LOGIC
|
// BEGIN AVATAR SELECTOR LOGIC
|
||||||
|
@ -180,7 +179,6 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
function color(selected, hovering) {
|
function color(selected, hovering) {
|
||||||
var base = hovering ? HOVER_COLOR : selected ? SELECTED_COLOR : UNSELECTED_COLOR;
|
var base = hovering ? HOVER_COLOR : selected ? SELECTED_COLOR : UNSELECTED_COLOR;
|
||||||
function scale(component) {
|
function scale(component) {
|
||||||
var delta = 0xFF - component;
|
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
return { red: scale(base.red), green: scale(base.green), blue: scale(base.blue) };
|
return { red: scale(base.red), green: scale(base.green), blue: scale(base.blue) };
|
||||||
|
@ -323,7 +321,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
method: 'updateSelectedRecipientUsername',
|
method: 'updateSelectedRecipientUsername',
|
||||||
userName: username === "" ? "unknown username" : username
|
userName: username === "" ? "unknown username" : username
|
||||||
};
|
};
|
||||||
sendToQml(message);
|
ui.tablet.sendToQml(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleClick(pickRay) {
|
function handleClick(pickRay) {
|
||||||
|
@ -341,7 +339,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
displayName: '"' + AvatarList.getAvatar(avatarId).sessionDisplayName + '"',
|
displayName: '"' + AvatarList.getAvatar(avatarId).sessionDisplayName + '"',
|
||||||
userName: ''
|
userName: ''
|
||||||
};
|
};
|
||||||
sendToQml(message);
|
ui.tablet.sendToQml(message);
|
||||||
|
|
||||||
ExtendedOverlay.some(function (overlay) {
|
ExtendedOverlay.some(function (overlay) {
|
||||||
var id = overlay.key;
|
var id = overlay.key;
|
||||||
|
@ -444,7 +442,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
{ x: 1, y: 0, z: 0 },
|
{ x: 1, y: 0, z: 0 },
|
||||||
{ x: 1, y: 0, z: 1 },
|
{ x: 1, y: 0, z: 1 },
|
||||||
{ x: 1, y: 1, z: 0 },
|
{ 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.
|
// Go through all corners and find least (most negative) distance in front of position.
|
||||||
|
@ -625,94 +623,66 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
|
|
||||||
var referrerURL; // Used for updating Purchases QML
|
var referrerURL; // Used for updating Purchases QML
|
||||||
var filterText; // Used for updating Purchases QML
|
var filterText; // Used for updating Purchases QML
|
||||||
function onMessage(message) {
|
function onWebEventReceived(message) {
|
||||||
if (message === GOTO_DIRECTORY) {
|
message = JSON.parse(message);
|
||||||
tablet.gotoWebScreen(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
if (message.type === GOTO_DIRECTORY) {
|
||||||
} else if (message === QUERY_CAN_WRITE_ASSETS) {
|
ui.open(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
} else if (message.type === QUERY_CAN_WRITE_ASSETS) {
|
||||||
} else if (message === WARN_USER_NO_PERMISSIONS) {
|
ui.sendToHtml(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||||
|
} else if (message.type === WARN_USER_NO_PERMISSIONS) {
|
||||||
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
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) {
|
if (isDownloadBeingCancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = message.slice(CLARA_IO_STATUS.length);
|
var text = message.status;
|
||||||
if (messageBox === null) {
|
if (messageBox === null) {
|
||||||
messageBox = Window.openMessageBox(CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
messageBox = Window.openMessageBox(CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
||||||
} else {
|
} else {
|
||||||
Window.updateMessageBox(messageBox, CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
Window.updateMessageBox(messageBox, CLARA_DOWNLOAD_TITLE, text, CANCEL_BUTTON, NO_BUTTON);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (message.slice(0, CLARA_IO_DOWNLOAD.length) === CLARA_IO_DOWNLOAD) {
|
} else if (message.type === CLARA_IO_DOWNLOAD) {
|
||||||
if (messageBox !== null) {
|
if (messageBox !== null) {
|
||||||
Window.closeMessageBox(messageBox);
|
Window.closeMessageBox(messageBox);
|
||||||
messageBox = null;
|
messageBox = null;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (message === CLARA_IO_CANCELLED_DOWNLOAD) {
|
} else if (message.type === CLARA_IO_CANCELLED_DOWNLOAD) {
|
||||||
isDownloadBeingCancelled = false;
|
isDownloadBeingCancelled = false;
|
||||||
} else {
|
} else if (message.type === "CHECKOUT") {
|
||||||
var parsedJsonMessage = JSON.parse(message);
|
wireQmlEventBridge(true);
|
||||||
if (parsedJsonMessage.type === "CHECKOUT") {
|
ui.open(MARKETPLACE_CHECKOUT_QML_PATH);
|
||||||
wireEventBridge(true);
|
ui.tablet.sendToQml({
|
||||||
tablet.pushOntoStack(MARKETPLACE_CHECKOUT_QML_PATH);
|
|
||||||
sendToQml({
|
|
||||||
method: 'updateCheckoutQML',
|
method: 'updateCheckoutQML',
|
||||||
params: parsedJsonMessage
|
params: message
|
||||||
});
|
});
|
||||||
} else if (parsedJsonMessage.type === "REQUEST_SETTING") {
|
} else if (message.type === "REQUEST_SETTING") {
|
||||||
sendCommerceSettings();
|
sendCommerceSettings();
|
||||||
} else if (parsedJsonMessage.type === "PURCHASES") {
|
} else if (message.type === "PURCHASES") {
|
||||||
referrerURL = parsedJsonMessage.referrerURL;
|
referrerURL = message.referrerURL;
|
||||||
filterText = "";
|
filterText = "";
|
||||||
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
} else if (parsedJsonMessage.type === "LOGIN") {
|
} else if (message.type === "LOGIN") {
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
} else if (parsedJsonMessage.type === "WALLET_SETUP") {
|
} else if (message.type === "WALLET_SETUP") {
|
||||||
wireEventBridge(true);
|
wireQmlEventBridge(true);
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'updateWalletReferrer',
|
method: 'updateWalletReferrer',
|
||||||
referrer: "marketplace cta"
|
referrer: "marketplace cta"
|
||||||
});
|
});
|
||||||
openWallet();
|
openWallet();
|
||||||
} else if (parsedJsonMessage.type === "MY_ITEMS") {
|
} else if (message.type === "MY_ITEMS") {
|
||||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||||
filterText = "";
|
filterText = "";
|
||||||
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
wireEventBridge(true);
|
wireQmlEventBridge(true);
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'purchases_showMyItems'
|
method: 'purchases_showMyItems'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function onButtonClicked() {
|
|
||||||
if (!tablet) {
|
|
||||||
print("Warning in buttonClicked(): 'tablet' undefined!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (onMarketplaceScreen || onCommerceScreen) {
|
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
if (HMD.tabletID) {
|
|
||||||
Entities.editEntity(HMD.tabletID, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
|
|
||||||
}
|
|
||||||
showMarketplace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function Name: sendToQml()
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
// -Use this function to send a message to the QML (i.e. to change appearances). The "message" argument is what is sent to
|
|
||||||
// the QML in the format "{method, params}", like json-rpc. See also fromQml().
|
|
||||||
function sendToQml(message) {
|
|
||||||
tablet.sendToQml(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var sendAssetRecipient;
|
var sendAssetRecipient;
|
||||||
var sendAssetParticleEffectUpdateTimer;
|
var sendAssetParticleEffectUpdateTimer;
|
||||||
var particleEffectTimestamp;
|
var particleEffectTimestamp;
|
||||||
|
@ -787,25 +757,21 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
sendAssetRecipient = null;
|
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() {
|
function maybeEnableHMDPreview() {
|
||||||
// Set a small timeout to prevent sensitive data from being shown during
|
// Set a small timeout to prevent sensitive data from being shown during UI fade
|
||||||
// UI fade
|
|
||||||
Script.setTimeout(function () {
|
Script.setTimeout(function () {
|
||||||
setTabletVisibleInSecondaryCamera(true);
|
setTabletVisibleInSecondaryCamera(true);
|
||||||
DesktopPreviewProvider.setPreviewDisabledReason("USER");
|
DesktopPreviewProvider.setPreviewDisabledReason("USER");
|
||||||
Menu.setIsOptionChecked("Disable Preview", savedDisablePreviewOption);
|
Menu.setIsOptionChecked("Disable Preview", savedDisablePreviewOption);
|
||||||
savedDisablePreviewOptionLocked = false;
|
}, UI_FADE_TIMEOUT_MS);
|
||||||
}, 150);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function Name: fromQml()
|
var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
//
|
if (message.messageSrc === "HTML") {
|
||||||
// Description:
|
return;
|
||||||
// -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) {
|
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'purchases_openWallet':
|
case 'purchases_openWallet':
|
||||||
case 'checkout_openWallet':
|
case 'checkout_openWallet':
|
||||||
|
@ -813,44 +779,40 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
openWallet();
|
openWallet();
|
||||||
break;
|
break;
|
||||||
case 'purchases_walletNotSetUp':
|
case 'purchases_walletNotSetUp':
|
||||||
wireEventBridge(true);
|
wireQmlEventBridge(true);
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'updateWalletReferrer',
|
method: 'updateWalletReferrer',
|
||||||
referrer: "purchases"
|
referrer: "purchases"
|
||||||
});
|
});
|
||||||
openWallet();
|
openWallet();
|
||||||
break;
|
break;
|
||||||
case 'checkout_walletNotSetUp':
|
case 'checkout_walletNotSetUp':
|
||||||
wireEventBridge(true);
|
wireQmlEventBridge(true);
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'updateWalletReferrer',
|
method: 'updateWalletReferrer',
|
||||||
referrer: message.referrer === "itemPage" ? message.itemId : message.referrer
|
referrer: message.referrer === "itemPage" ? message.itemId : message.referrer
|
||||||
});
|
});
|
||||||
openWallet();
|
openWallet();
|
||||||
break;
|
break;
|
||||||
case 'checkout_cancelClicked':
|
case 'checkout_cancelClicked':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
// TODO: Make Marketplace a QML app that's a WebView wrapper so we can use the app stack.
|
|
||||||
// I don't think this is trivial to do since we also want to inject some JS into the DOM.
|
|
||||||
//tablet.popFromStack();
|
|
||||||
break;
|
break;
|
||||||
case 'header_goToPurchases':
|
case 'header_goToPurchases':
|
||||||
case 'checkout_goToPurchases':
|
case 'checkout_goToPurchases':
|
||||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||||
filterText = message.filterText;
|
filterText = message.filterText;
|
||||||
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
break;
|
break;
|
||||||
case 'checkout_itemLinkClicked':
|
case 'checkout_itemLinkClicked':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'checkout_continueShopping':
|
case 'checkout_continueShopping':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
//tablet.popFromStack();
|
|
||||||
break;
|
break;
|
||||||
case 'purchases_itemInfoClicked':
|
case 'purchases_itemInfoClicked':
|
||||||
var itemId = message.itemId;
|
var itemId = message.itemId;
|
||||||
if (itemId && itemId !== "") {
|
if (itemId && itemId !== "") {
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'checkout_rezClicked':
|
case 'checkout_rezClicked':
|
||||||
|
@ -859,13 +821,13 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
break;
|
break;
|
||||||
case 'header_marketplaceImageClicked':
|
case 'header_marketplaceImageClicked':
|
||||||
case 'purchases_backClicked':
|
case 'purchases_backClicked':
|
||||||
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'purchases_goToMarketplaceClicked':
|
case 'purchases_goToMarketplaceClicked':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'updateItemClicked':
|
case 'updateItemClicked':
|
||||||
tablet.gotoWebScreen(message.upgradeUrl + "?edition=" + message.itemEdition,
|
ui.open(message.upgradeUrl + "?edition=" + message.itemEdition,
|
||||||
MARKETPLACES_INJECT_SCRIPT_URL);
|
MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'giftAsset':
|
case 'giftAsset':
|
||||||
|
@ -873,7 +835,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
break;
|
break;
|
||||||
case 'passphrasePopup_cancelClicked':
|
case 'passphrasePopup_cancelClicked':
|
||||||
case 'needsLogIn_cancelClicked':
|
case 'needsLogIn_cancelClicked':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'needsLogIn_loginClicked':
|
case 'needsLogIn_loginClicked':
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
|
@ -881,7 +843,6 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
case 'disableHmdPreview':
|
case 'disableHmdPreview':
|
||||||
if (!savedDisablePreviewOption) {
|
if (!savedDisablePreviewOption) {
|
||||||
savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
||||||
savedDisablePreviewOptionLocked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!savedDisablePreviewOption) {
|
if (!savedDisablePreviewOption) {
|
||||||
|
@ -894,26 +855,27 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
maybeEnableHMDPreview();
|
maybeEnableHMDPreview();
|
||||||
break;
|
break;
|
||||||
case 'purchases_openGoTo':
|
case 'purchases_openGoTo':
|
||||||
tablet.loadQMLSource("hifi/tablet/TabletAddressDialog.qml");
|
ui.open("hifi/tablet/TabletAddressDialog.qml");
|
||||||
break;
|
break;
|
||||||
case 'purchases_itemCertificateClicked':
|
case 'purchases_itemCertificateClicked':
|
||||||
setCertificateInfo("", message.itemCertificateId);
|
contextOverlayEntity = "";
|
||||||
|
setCertificateInfo(contextOverlayEntity, message.itemCertificateId);
|
||||||
break;
|
break;
|
||||||
case 'inspectionCertificate_closeClicked':
|
case 'inspectionCertificate_closeClicked':
|
||||||
tablet.gotoHomeScreen();
|
ui.close();
|
||||||
break;
|
break;
|
||||||
case 'inspectionCertificate_requestOwnershipVerification':
|
case 'inspectionCertificate_requestOwnershipVerification':
|
||||||
ContextOverlay.requestOwnershipVerification(message.entity);
|
ContextOverlay.requestOwnershipVerification(message.entity);
|
||||||
break;
|
break;
|
||||||
case 'inspectionCertificate_showInMarketplaceClicked':
|
case 'inspectionCertificate_showInMarketplaceClicked':
|
||||||
tablet.gotoWebScreen(message.marketplaceUrl, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(message.marketplaceUrl, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'header_myItemsClicked':
|
case 'header_myItemsClicked':
|
||||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||||
filterText = "";
|
filterText = "";
|
||||||
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
wireEventBridge(true);
|
wireQmlEventBridge(true);
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'purchases_showMyItems'
|
method: 'purchases_showMyItems'
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -949,7 +911,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
case 'wallet_availableUpdatesReceived':
|
case 'wallet_availableUpdatesReceived':
|
||||||
case 'purchases_availableUpdatesReceived':
|
case 'purchases_availableUpdatesReceived':
|
||||||
userHasUpdates = message.numUpdates > 0;
|
userHasUpdates = message.numUpdates > 0;
|
||||||
messagesWaiting(userHasUpdates);
|
ui.messagesWaiting(userHasUpdates);
|
||||||
break;
|
break;
|
||||||
case 'purchases_updateWearables':
|
case 'purchases_updateWearables':
|
||||||
var currentlyWornWearables = [];
|
var currentlyWornWearables = [];
|
||||||
|
@ -958,7 +920,9 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
var nearbyEntities = Entities.findEntitiesByType('Model', MyAvatar.position, ATTACHMENT_SEARCH_RADIUS);
|
var nearbyEntities = Entities.findEntitiesByType('Model', MyAvatar.position, ATTACHMENT_SEARCH_RADIUS);
|
||||||
|
|
||||||
for (var i = 0; i < nearbyEntities.length; i++) {
|
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) {
|
if (currentProperties.parentID === MyAvatar.sessionUUID) {
|
||||||
currentlyWornWearables.push({
|
currentlyWornWearables.push({
|
||||||
entityID: nearbyEntities[i],
|
entityID: nearbyEntities[i],
|
||||||
|
@ -968,13 +932,12 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToQml({ method: 'updateWearables', wornWearables: currentlyWornWearables });
|
ui.tablet.sendToQml({ method: 'updateWearables', wornWearables: currentlyWornWearables });
|
||||||
break;
|
break;
|
||||||
case 'sendAsset_sendPublicly':
|
case 'sendAsset_sendPublicly':
|
||||||
if (message.assetName !== "") {
|
if (message.assetName !== "") {
|
||||||
deleteSendAssetParticleEffect();
|
deleteSendAssetParticleEffect();
|
||||||
sendAssetRecipient = message.recipient;
|
sendAssetRecipient = message.recipient;
|
||||||
var amount = message.amount;
|
|
||||||
var props = SEND_ASSET_PARTICLE_PROPERTIES;
|
var props = SEND_ASSET_PARTICLE_PROPERTIES;
|
||||||
props.parentID = MyAvatar.sessionUUID;
|
props.parentID = MyAvatar.sessionUUID;
|
||||||
props.position = MyAvatar.position;
|
props.position = MyAvatar.position;
|
||||||
|
@ -985,7 +948,8 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
sendAssetParticleEffect = Entities.addEntity(props, true);
|
sendAssetParticleEffect = Entities.addEntity(props, true);
|
||||||
particleEffectTimestamp = Date.now();
|
particleEffectTimestamp = Date.now();
|
||||||
updateSendAssetParticleEffect();
|
updateSendAssetParticleEffect();
|
||||||
sendAssetParticleEffectUpdateTimer = Script.setInterval(updateSendAssetParticleEffect, SEND_ASSET_PARTICLE_TIMER_UPDATE);
|
sendAssetParticleEffectUpdateTimer = Script.setInterval(updateSendAssetParticleEffect,
|
||||||
|
SEND_ASSET_PARTICLE_TIMER_UPDATE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'http.request':
|
case 'http.request':
|
||||||
|
@ -996,74 +960,56 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
default:
|
default:
|
||||||
print('Unrecognized message from Checkout.qml or Purchases.qml: ' + JSON.stringify(message));
|
print('Unrecognized message from Checkout.qml or Purchases.qml: ' + JSON.stringify(message));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Function Name: wireEventBridge()
|
|
||||||
//
|
|
||||||
// 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 wireEventBridge(on) {
|
|
||||||
if (!tablet) {
|
|
||||||
print("Warning in wireEventBridge(): 'tablet' undefined!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (on) {
|
|
||||||
if (!hasEventBridge) {
|
|
||||||
tablet.fromQml.connect(fromQml);
|
|
||||||
hasEventBridge = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (hasEventBridge) {
|
|
||||||
tablet.fromQml.disconnect(fromQml);
|
|
||||||
hasEventBridge = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function Name: onTabletScreenChanged()
|
// Function Name: onTabletScreenChanged()
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
|
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
|
||||||
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
|
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
|
||||||
|
var onMarketplaceScreen = false;
|
||||||
var onWalletScreen = false;
|
var onWalletScreen = false;
|
||||||
var onCommerceScreen = 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;
|
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 onWalletScreenNow = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1;
|
||||||
var onCommerceScreenNow = type === "QML" && (url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 || url === MARKETPLACE_PURCHASES_QML_PATH
|
var onCommerceScreenNow = type === "QML" &&
|
||||||
|| url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1);
|
(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();
|
maybeEnableHMDPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
onCommerceScreen = onCommerceScreenNow;
|
onCommerceScreen = onCommerceScreenNow;
|
||||||
onWalletScreen = onWalletScreenNow;
|
onWalletScreen = onWalletScreenNow;
|
||||||
wireEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen);
|
wireQmlEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen);
|
||||||
|
|
||||||
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
||||||
sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'updatePurchases',
|
method: 'updatePurchases',
|
||||||
referrerURL: referrerURL,
|
referrerURL: referrerURL,
|
||||||
filterText: filterText
|
filterText: filterText
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
ui.isOpen = (onMarketplaceScreen || onCommerceScreen) && !onWalletScreen;
|
||||||
if (marketplaceButton) {
|
ui.buttonActive(ui.isOpen);
|
||||||
marketplaceButton.editProperties({ isActive: (onMarketplaceScreen || onCommerceScreen) && !onWalletScreen });
|
|
||||||
}
|
|
||||||
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
||||||
ContextOverlay.isInMarketplaceInspectionMode = true;
|
ContextOverlay.isInMarketplaceInspectionMode = true;
|
||||||
} else {
|
} else {
|
||||||
ContextOverlay.isInMarketplaceInspectionMode = false;
|
ContextOverlay.isInMarketplaceInspectionMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onInspectionCertificateScreen) {
|
||||||
|
setCertificateInfo(contextOverlayEntity);
|
||||||
|
}
|
||||||
|
|
||||||
if (onCommerceScreen) {
|
if (onCommerceScreen) {
|
||||||
if (!isWired) {
|
if (!isWired) {
|
||||||
Users.usernameFromIDReply.connect(usernameFromIDReply);
|
Users.usernameFromIDReply.connect(usernameFromIDReply);
|
||||||
|
@ -1075,43 +1021,41 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
isWired = true;
|
isWired = true;
|
||||||
Wallet.refreshWalletStatus();
|
Wallet.refreshWalletStatus();
|
||||||
} else {
|
} else {
|
||||||
off();
|
ui.tablet.sendToQml({
|
||||||
sendToQml({
|
|
||||||
method: 'inspectionCertificate_resetCert'
|
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.
|
// Manage the connection between the button and the window.
|
||||||
//
|
//
|
||||||
var marketplaceButton;
|
var BUTTON_NAME = "MARKET";
|
||||||
var buttonName = "MARKET";
|
var MARKETPLACE_URL = METAVERSE_SERVER_URL + "/marketplace";
|
||||||
var tablet = null;
|
var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
||||||
var NORMAL_ICON = "icons/tablet-icons/market-i.svg";
|
var ui;
|
||||||
var NORMAL_ACTIVE = "icons/tablet-icons/market-a.svg";
|
|
||||||
var WAITING_ICON = "icons/tablet-icons/market-i-msg.svg";
|
|
||||||
var WAITING_ACTIVE = "icons/tablet-icons/market-a-msg.svg";
|
|
||||||
function startup() {
|
function startup() {
|
||||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
ui = new AppUi({
|
||||||
marketplaceButton = tablet.addButton({
|
buttonName: BUTTON_NAME,
|
||||||
icon: NORMAL_ICON,
|
sortOrder: 9,
|
||||||
activeIcon: NORMAL_ACTIVE,
|
inject: MARKETPLACES_INJECT_SCRIPT_URL,
|
||||||
text: buttonName,
|
home: MARKETPLACE_URL_INITIAL,
|
||||||
sortOrder: 9
|
onScreenChanged: onTabletScreenChanged,
|
||||||
|
onMessage: onQmlMessageReceived
|
||||||
});
|
});
|
||||||
|
ContextOverlay.contextOverlayClicked.connect(openInspectionCertificateQML);
|
||||||
ContextOverlay.contextOverlayClicked.connect(setCertificateInfo);
|
|
||||||
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||||
marketplaceButton.clicked.connect(onButtonClicked);
|
ui.tablet.webEventReceived.connect(onWebEventReceived);
|
||||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
|
||||||
tablet.webEventReceived.connect(onMessage);
|
|
||||||
Wallet.walletStatusChanged.connect(sendCommerceSettings);
|
Wallet.walletStatusChanged.connect(sendCommerceSettings);
|
||||||
Window.messageBoxClosed.connect(onMessageBoxClosed);
|
Window.messageBoxClosed.connect(onMessageBoxClosed);
|
||||||
|
|
||||||
Wallet.refreshWalletStatus();
|
Wallet.refreshWalletStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
var isWired = false;
|
var isWired = false;
|
||||||
var isUpdateOverlaysWired = false;
|
var isUpdateOverlaysWired = false;
|
||||||
function off() {
|
function off() {
|
||||||
|
@ -1124,6 +1068,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
|
|
||||||
isWired = false;
|
isWired = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUpdateOverlaysWired) {
|
if (isUpdateOverlaysWired) {
|
||||||
Script.update.disconnect(updateOverlays);
|
Script.update.disconnect(updateOverlays);
|
||||||
isUpdateOverlaysWired = false;
|
isUpdateOverlaysWired = false;
|
||||||
|
@ -1134,21 +1079,12 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
maybeEnableHMDPreview();
|
maybeEnableHMDPreview();
|
||||||
deleteSendAssetParticleEffect();
|
deleteSendAssetParticleEffect();
|
||||||
|
|
||||||
ContextOverlay.contextOverlayClicked.disconnect(setCertificateInfo);
|
|
||||||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
|
||||||
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
|
||||||
marketplaceButton.clicked.disconnect(onButtonClicked);
|
|
||||||
tablet.removeButton(marketplaceButton);
|
|
||||||
tablet.webEventReceived.disconnect(onMessage);
|
|
||||||
Wallet.walletStatusChanged.disconnect(sendCommerceSettings);
|
|
||||||
Window.messageBoxClosed.disconnect(onMessageBoxClosed);
|
Window.messageBoxClosed.disconnect(onMessageBoxClosed);
|
||||||
|
Wallet.walletStatusChanged.disconnect(sendCommerceSettings);
|
||||||
if (tablet) {
|
ui.tablet.webEventReceived.disconnect(onWebEventReceived);
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||||
if (onMarketplaceScreen) {
|
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||||
tablet.gotoHomeScreen();
|
ContextOverlay.contextOverlayClicked.disconnect(openInspectionCertificateQML);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
@ -1158,5 +1094,4 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
//
|
//
|
||||||
startup();
|
startup();
|
||||||
Script.scriptEnding.connect(shutdown);
|
Script.scriptEnding.connect(shutdown);
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/* jslint vars:true, plusplus:true, forin:true */
|
/* jslint vars:true, plusplus:true, forin:true */
|
||||||
/*global Tablet, Settings, Script, AvatarList, Users, Entities, MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account, UserActivityLogger, Messages, Window, XMLHttpRequest, print, location, getControllerWorldLocation*/
|
/* global Tablet, Settings, Script, AvatarList, Users, Entities,
|
||||||
|
MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account,
|
||||||
|
UserActivityLogger, Messages, Window, XMLHttpRequest, print, location, getControllerWorldLocation
|
||||||
|
*/
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
//
|
//
|
||||||
// pal.js
|
// pal.js
|
||||||
|
@ -20,7 +23,7 @@ var AppUi = Script.require('appUi');
|
||||||
var populateNearbyUserList, color, textures, removeOverlays,
|
var populateNearbyUserList, color, textures, removeOverlays,
|
||||||
controllerComputePickRay, off,
|
controllerComputePickRay, off,
|
||||||
receiveMessage, avatarDisconnected, clearLocalQMLDataAndClosePAL,
|
receiveMessage, avatarDisconnected, clearLocalQMLDataAndClosePAL,
|
||||||
CHANNEL, getConnectionData, findableByChanged,
|
CHANNEL, getConnectionData,
|
||||||
avatarAdded, avatarRemoved, avatarSessionChanged; // forward references;
|
avatarAdded, avatarRemoved, avatarSessionChanged; // forward references;
|
||||||
|
|
||||||
// hardcoding these as it appears we cannot traverse the originalTextures in overlays??? Maybe I've missed
|
// hardcoding these as it appears we cannot traverse the originalTextures in overlays??? Maybe I've missed
|
||||||
|
@ -318,6 +321,10 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
||||||
break;
|
break;
|
||||||
case 'http.request':
|
case 'http.request':
|
||||||
break; // Handled by request-service.
|
break; // Handled by request-service.
|
||||||
|
case 'hideNotificationDot':
|
||||||
|
shouldShowDot = false;
|
||||||
|
ui.messagesWaiting(shouldShowDot);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print('Unrecognized message from Pal.qml:', JSON.stringify(message));
|
print('Unrecognized message from Pal.qml:', JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
@ -361,8 +368,8 @@ function getProfilePicture(username, callback) { // callback(url) if successfull
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var SAFETY_LIMIT = 400;
|
var SAFETY_LIMIT = 400;
|
||||||
function getAvailableConnections(domain, callback) { // callback([{usename, location}...]) if successfull. (Logs otherwise)
|
function getAvailableConnections(domain, callback, numResultsPerPage) { // callback([{usename, location}...]) if successfull. (Logs otherwise)
|
||||||
var url = METAVERSE_BASE + '/api/v1/users?per_page=' + SAFETY_LIMIT + '&';
|
var url = METAVERSE_BASE + '/api/v1/users?per_page=' + (numResultsPerPage || SAFETY_LIMIT) + '&';
|
||||||
if (domain) {
|
if (domain) {
|
||||||
url += 'status=' + domain.slice(1, -1); // without curly braces
|
url += 'status=' + domain.slice(1, -1); // without curly braces
|
||||||
} else {
|
} else {
|
||||||
|
@ -725,10 +732,14 @@ function createUpdateInterval() {
|
||||||
|
|
||||||
var previousContextOverlay = ContextOverlay.enabled;
|
var previousContextOverlay = ContextOverlay.enabled;
|
||||||
var previousRequestsDomainListData = Users.requestsDomainListData;
|
var previousRequestsDomainListData = Users.requestsDomainListData;
|
||||||
function on() {
|
function palOpened() {
|
||||||
|
ui.sendMessage({
|
||||||
|
method: 'changeConnectionsDotStatus',
|
||||||
|
shouldShowDot: shouldShowDot
|
||||||
|
});
|
||||||
|
|
||||||
previousContextOverlay = ContextOverlay.enabled;
|
previousContextOverlay = ContextOverlay.enabled;
|
||||||
previousRequestsDomainListData = Users.requestsDomainListData
|
previousRequestsDomainListData = Users.requestsDomainListData;
|
||||||
ContextOverlay.enabled = false;
|
ContextOverlay.enabled = false;
|
||||||
Users.requestsDomainListData = true;
|
Users.requestsDomainListData = true;
|
||||||
|
|
||||||
|
@ -807,14 +818,98 @@ function avatarSessionChanged(avatarID) {
|
||||||
sendToQml({ method: 'palIsStale', params: [avatarID, 'avatarSessionChanged'] });
|
sendToQml({ method: 'palIsStale', params: [avatarID, 'avatarSessionChanged'] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notificationDataProcessPage(data) {
|
||||||
|
return data.data.users;
|
||||||
|
}
|
||||||
|
|
||||||
|
var shouldShowDot = false;
|
||||||
|
var storedOnlineUsersArray = [];
|
||||||
|
function notificationPollCallback(connectionsArray) {
|
||||||
|
//
|
||||||
|
// START logic for handling online/offline user changes
|
||||||
|
//
|
||||||
|
var i, j;
|
||||||
|
var newlyOnlineConnectionsArray = [];
|
||||||
|
for (i = 0; i < connectionsArray.length; i++) {
|
||||||
|
var currentUser = connectionsArray[i];
|
||||||
|
|
||||||
|
if (connectionsArray[i].online) {
|
||||||
|
var indexOfStoredOnlineUser = -1;
|
||||||
|
for (j = 0; j < storedOnlineUsersArray.length; j++) {
|
||||||
|
if (currentUser.username === storedOnlineUsersArray[j].username) {
|
||||||
|
indexOfStoredOnlineUser = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the user record isn't already presesnt inside `storedOnlineUsersArray`...
|
||||||
|
if (indexOfStoredOnlineUser < 0) {
|
||||||
|
storedOnlineUsersArray.push(currentUser);
|
||||||
|
newlyOnlineConnectionsArray.push(currentUser);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var indexOfOfflineUser = -1;
|
||||||
|
for (j = 0; j < storedOnlineUsersArray.length; j++) {
|
||||||
|
if (currentUser.username === storedOnlineUsersArray[j].username) {
|
||||||
|
indexOfOfflineUser = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (indexOfOfflineUser >= 0) {
|
||||||
|
storedOnlineUsersArray.splice(indexOfOfflineUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If there's new data, the light should turn on.
|
||||||
|
// If the light is already on and you have connections online, the light should stay on.
|
||||||
|
// In all other cases, the light should turn off or stay off.
|
||||||
|
shouldShowDot = newlyOnlineConnectionsArray.length > 0 || (storedOnlineUsersArray.length > 0 && shouldShowDot);
|
||||||
|
//
|
||||||
|
// END logic for handling online/offline user changes
|
||||||
|
//
|
||||||
|
|
||||||
|
if (!ui.isOpen) {
|
||||||
|
ui.messagesWaiting(shouldShowDot);
|
||||||
|
ui.sendMessage({
|
||||||
|
method: 'changeConnectionsDotStatus',
|
||||||
|
shouldShowDot: shouldShowDot
|
||||||
|
});
|
||||||
|
|
||||||
|
if (newlyOnlineConnectionsArray.length > 0) {
|
||||||
|
var message;
|
||||||
|
if (!ui.notificationInitialCallbackMade) {
|
||||||
|
message = newlyOnlineConnectionsArray.length + " of your connections " +
|
||||||
|
(newlyOnlineConnectionsArray.length === 1 ? "is" : "are") + " online. Open PEOPLE to join them!";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < newlyOnlineConnectionsArray.length; i++) {
|
||||||
|
message = newlyOnlineConnectionsArray[i].username + " is available in " +
|
||||||
|
newlyOnlineConnectionsArray[i].location.root.name + ". Open PEOPLE to join them!";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReturnedDataEmpty(data) {
|
||||||
|
var usersArray = data.data.users;
|
||||||
|
return usersArray.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
function startup() {
|
function startup() {
|
||||||
ui = new AppUi({
|
ui = new AppUi({
|
||||||
buttonName: "PEOPLE",
|
buttonName: "PEOPLE",
|
||||||
sortOrder: 7,
|
sortOrder: 7,
|
||||||
home: "hifi/Pal.qml",
|
home: "hifi/Pal.qml",
|
||||||
onOpened: on,
|
onOpened: palOpened,
|
||||||
onClosed: off,
|
onClosed: off,
|
||||||
onMessage: fromQml
|
onMessage: fromQml,
|
||||||
|
notificationPollEndpoint: "/api/v1/users?filter=connections&per_page=10",
|
||||||
|
notificationPollTimeoutMs: 60000,
|
||||||
|
notificationDataProcessPage: notificationDataProcessPage,
|
||||||
|
notificationPollCallback: notificationPollCallback,
|
||||||
|
notificationPollStopPaginatingConditionMet: isReturnedDataEmpty,
|
||||||
|
notificationPollCaresAboutSince: false
|
||||||
});
|
});
|
||||||
Window.domainChanged.connect(clearLocalQMLDataAndClosePAL);
|
Window.domainChanged.connect(clearLocalQMLDataAndClosePAL);
|
||||||
Window.domainConnectionRefused.connect(clearLocalQMLDataAndClosePAL);
|
Window.domainConnectionRefused.connect(clearLocalQMLDataAndClosePAL);
|
||||||
|
|
|
@ -7,28 +7,19 @@
|
||||||
// Distributed under the Apache License, Version 2.0
|
// Distributed under the Apache License, Version 2.0
|
||||||
// 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
|
||||||
//
|
//
|
||||||
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle, OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle,
|
||||||
|
OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
Script.include("/~/system/libraries/accountUtils.js");
|
Script.include("/~/system/libraries/accountUtils.js");
|
||||||
|
var AppUi = Script.require('appUi');
|
||||||
|
|
||||||
var SNAPSHOT_DELAY = 500; // 500ms
|
var SNAPSHOT_DELAY = 500; // 500ms
|
||||||
var FINISH_SOUND_DELAY = 350;
|
var FINISH_SOUND_DELAY = 350;
|
||||||
var resetOverlays;
|
var resetOverlays;
|
||||||
var reticleVisible;
|
var reticleVisible;
|
||||||
|
|
||||||
var buttonName = "SNAP";
|
|
||||||
var buttonConnected = false;
|
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
||||||
var button = tablet.addButton({
|
|
||||||
icon: "icons/tablet-icons/snap-i.svg",
|
|
||||||
activeIcon: "icons/tablet-icons/snap-a.svg",
|
|
||||||
text: buttonName,
|
|
||||||
sortOrder: 5
|
|
||||||
});
|
|
||||||
|
|
||||||
var snapshotOptions = {};
|
var snapshotOptions = {};
|
||||||
var imageData = [];
|
var imageData = [];
|
||||||
var storyIDsToMaybeDelete = [];
|
var storyIDsToMaybeDelete = [];
|
||||||
|
@ -52,8 +43,6 @@ try {
|
||||||
print('Failed to resolve request api, error: ' + err);
|
print('Failed to resolve request api, error: ' + err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function removeFromStoryIDsToMaybeDelete(story_id) {
|
function removeFromStoryIDsToMaybeDelete(story_id) {
|
||||||
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(story_id), 1);
|
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(story_id), 1);
|
||||||
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
|
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
|
||||||
|
@ -73,33 +62,32 @@ function onMessage(message) {
|
||||||
// 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the
|
// 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the
|
||||||
// same time, show the user all of them, and have the user deselect any that they do not want to share.
|
// same time, show the user all of them, and have the user deselect any that they do not want to share.
|
||||||
// So we'll ultimately be receiving a set of objects, perhaps with different post processing for each.
|
// So we'll ultimately be receiving a set of objects, perhaps with different post processing for each.
|
||||||
message = JSON.parse(message);
|
|
||||||
if (message.type !== "snapshot") {
|
if (message.type !== "snapshot") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message.action) {
|
switch (message.action) {
|
||||||
case 'ready': // DOM is ready and page has loaded
|
case 'ready': // DOM is ready and page has loaded
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "captureSettings",
|
action: "captureSettings",
|
||||||
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
|
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
|
||||||
}));
|
});
|
||||||
if (Snapshot.getSnapshotsLocation() !== "") {
|
if (Snapshot.getSnapshotsLocation() !== "") {
|
||||||
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "showPreviousImages",
|
action: "showPreviousImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData,
|
image_data: imageData,
|
||||||
canShare: canShare
|
canShare: canShare
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "showSetupInstructions"
|
action: "showSetupInstructions"
|
||||||
}));
|
});
|
||||||
Settings.setValue("previousStillSnapPath", "");
|
Settings.setValue("previousStillSnapPath", "");
|
||||||
Settings.setValue("previousStillSnapStoryID", "");
|
Settings.setValue("previousStillSnapStoryID", "");
|
||||||
Settings.setValue("previousStillSnapBlastingDisabled", false);
|
Settings.setValue("previousStillSnapBlastingDisabled", false);
|
||||||
|
@ -124,7 +112,7 @@ function onMessage(message) {
|
||||||
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", true))) {
|
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", true))) {
|
||||||
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");
|
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");
|
||||||
} else {
|
} else {
|
||||||
tablet.loadQMLOnTop("hifi/tablet/TabletGeneralPreferences.qml");
|
ui.openNewAppOnTop("hifi/tablet/TabletGeneralPreferences.qml");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'captureStillAndGif':
|
case 'captureStillAndGif':
|
||||||
|
@ -284,7 +272,6 @@ var POLAROID_RATE_LIMIT_MS = 1000;
|
||||||
var polaroidPrintingIsRateLimited = false;
|
var polaroidPrintingIsRateLimited = false;
|
||||||
|
|
||||||
function printToPolaroid(image_url) {
|
function printToPolaroid(image_url) {
|
||||||
|
|
||||||
// Rate-limit printing
|
// Rate-limit printing
|
||||||
if (polaroidPrintingIsRateLimited) {
|
if (polaroidPrintingIsRateLimited) {
|
||||||
return;
|
return;
|
||||||
|
@ -376,19 +363,6 @@ function fillImageDataFromPrevious() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
|
|
||||||
var isInSnapshotReview = false;
|
|
||||||
function onButtonClicked() {
|
|
||||||
if (isInSnapshotReview){
|
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
fillImageDataFromPrevious();
|
|
||||||
tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL);
|
|
||||||
HMD.openTablet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function snapshotUploaded(isError, reply) {
|
function snapshotUploaded(isError, reply) {
|
||||||
if (!isError) {
|
if (!isError) {
|
||||||
var replyJson = JSON.parse(reply),
|
var replyJson = JSON.parse(reply),
|
||||||
|
@ -409,12 +383,12 @@ function snapshotUploaded(isError, reply) {
|
||||||
}
|
}
|
||||||
if ((isGif && !ignoreGifSnapshotData) || (!isGif && !ignoreStillSnapshotData)) {
|
if ((isGif && !ignoreGifSnapshotData) || (!isGif && !ignoreStillSnapshotData)) {
|
||||||
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "snapshotUploadComplete",
|
action: "snapshotUploadComplete",
|
||||||
story_id: storyID,
|
story_id: storyID,
|
||||||
image_url: imageURL,
|
image_url: imageURL,
|
||||||
}));
|
});
|
||||||
if (isGif) {
|
if (isGif) {
|
||||||
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,10 +403,10 @@ function snapshotUploaded(isError, reply) {
|
||||||
}
|
}
|
||||||
var href, snapshotDomainID;
|
var href, snapshotDomainID;
|
||||||
function takeSnapshot() {
|
function takeSnapshot() {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "clearPreviousImages"
|
action: "clearPreviousImages"
|
||||||
}));
|
});
|
||||||
Settings.setValue("previousStillSnapPath", "");
|
Settings.setValue("previousStillSnapPath", "");
|
||||||
Settings.setValue("previousStillSnapStoryID", "");
|
Settings.setValue("previousStillSnapStoryID", "");
|
||||||
Settings.setValue("previousStillSnapBlastingDisabled", false);
|
Settings.setValue("previousStillSnapBlastingDisabled", false);
|
||||||
|
@ -471,10 +445,6 @@ function takeSnapshot() {
|
||||||
} else {
|
} else {
|
||||||
Window.stillSnapshotTaken.connect(stillSnapshotTaken);
|
Window.stillSnapshotTaken.connect(stillSnapshotTaken);
|
||||||
}
|
}
|
||||||
if (buttonConnected) {
|
|
||||||
button.clicked.disconnect(onButtonClicked);
|
|
||||||
buttonConnected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide overlays if they are on
|
// hide overlays if they are on
|
||||||
if (resetOverlays) {
|
if (resetOverlays) {
|
||||||
|
@ -538,10 +508,6 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
||||||
Menu.setIsOptionChecked("Show Overlays", true);
|
Menu.setIsOptionChecked("Show Overlays", true);
|
||||||
}
|
}
|
||||||
Window.stillSnapshotTaken.disconnect(stillSnapshotTaken);
|
Window.stillSnapshotTaken.disconnect(stillSnapshotTaken);
|
||||||
if (!buttonConnected) {
|
|
||||||
button.clicked.connect(onButtonClicked);
|
|
||||||
buttonConnected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Snapshot Review dialog might be left open indefinitely after taking the picture,
|
// A Snapshot Review dialog might be left open indefinitely after taking the picture,
|
||||||
// during which time the user may have moved. So stash that info in the dialog so that
|
// during which time the user may have moved. So stash that info in the dialog so that
|
||||||
|
@ -559,12 +525,12 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
||||||
isLoggedIn: isLoggedIn
|
isLoggedIn: isLoggedIn
|
||||||
};
|
};
|
||||||
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "addImages",
|
action: "addImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData
|
image_data: imageData
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,10 +538,10 @@ function snapshotDirChanged(snapshotPath) {
|
||||||
Window.browseDirChanged.disconnect(snapshotDirChanged);
|
Window.browseDirChanged.disconnect(snapshotDirChanged);
|
||||||
if (snapshotPath !== "") { // not cancelled
|
if (snapshotPath !== "") { // not cancelled
|
||||||
Snapshot.setSnapshotsLocation(snapshotPath);
|
Snapshot.setSnapshotsLocation(snapshotPath);
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "snapshotLocationChosen"
|
action: "snapshotLocationChosen"
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,22 +569,18 @@ function processingGifStarted(pathStillSnapshot) {
|
||||||
isLoggedIn: isLoggedIn
|
isLoggedIn: isLoggedIn
|
||||||
};
|
};
|
||||||
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "addImages",
|
action: "addImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData
|
image_data: imageData
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function processingGifCompleted(pathAnimatedSnapshot) {
|
function processingGifCompleted(pathAnimatedSnapshot) {
|
||||||
isLoggedIn = Account.isLoggedIn();
|
isLoggedIn = Account.isLoggedIn();
|
||||||
Window.processingGifCompleted.disconnect(processingGifCompleted);
|
Window.processingGifCompleted.disconnect(processingGifCompleted);
|
||||||
if (!buttonConnected) {
|
|
||||||
button.clicked.connect(onButtonClicked);
|
|
||||||
buttonConnected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings.setValue("previousAnimatedSnapPath", pathAnimatedSnapshot);
|
Settings.setValue("previousAnimatedSnapPath", pathAnimatedSnapshot);
|
||||||
|
|
||||||
|
@ -631,12 +593,12 @@ function processingGifCompleted(pathAnimatedSnapshot) {
|
||||||
canBlast: location.domainID === Settings.getValue("previousSnapshotDomainID"),
|
canBlast: location.domainID === Settings.getValue("previousSnapshotDomainID"),
|
||||||
};
|
};
|
||||||
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
|
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "addImages",
|
action: "addImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData
|
image_data: imageData
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function maybeDeleteSnapshotStories() {
|
function maybeDeleteSnapshotStories() {
|
||||||
|
@ -655,28 +617,16 @@ function maybeDeleteSnapshotStories() {
|
||||||
});
|
});
|
||||||
storyIDsToMaybeDelete = [];
|
storyIDsToMaybeDelete = [];
|
||||||
}
|
}
|
||||||
function onTabletScreenChanged(type, url) {
|
|
||||||
var wasInSnapshotReview = isInSnapshotReview;
|
|
||||||
isInSnapshotReview = (type === "Web" && url === SNAPSHOT_REVIEW_URL);
|
|
||||||
button.editProperties({ isActive: isInSnapshotReview });
|
|
||||||
if (isInSnapshotReview !== wasInSnapshotReview) {
|
|
||||||
if (isInSnapshotReview) {
|
|
||||||
tablet.webEventReceived.connect(onMessage);
|
|
||||||
} else {
|
|
||||||
tablet.webEventReceived.disconnect(onMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function onUsernameChanged() {
|
function onUsernameChanged() {
|
||||||
fillImageDataFromPrevious();
|
fillImageDataFromPrevious();
|
||||||
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "showPreviousImages",
|
action: "showPreviousImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData,
|
image_data: imageData,
|
||||||
canShare: canShare
|
canShare: canShare
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
if (shareAfterLogin) {
|
if (shareAfterLogin) {
|
||||||
|
@ -705,10 +655,10 @@ function onUsernameChanged() {
|
||||||
|
|
||||||
function snapshotLocationSet(location) {
|
function snapshotLocationSet(location) {
|
||||||
if (location !== "") {
|
if (location !== "") {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "snapshotLocationChosen"
|
action: "snapshotLocationChosen"
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,36 +683,36 @@ function processRezPermissionChange(canRez) {
|
||||||
action = 'setPrintButtonDisabled';
|
action = 'setPrintButtonDisabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
ui.sendMessage({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action : action
|
action : action
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
button.clicked.connect(onButtonClicked);
|
function startup() {
|
||||||
buttonConnected = true;
|
ui = new AppUi({
|
||||||
|
buttonName: "SNAP",
|
||||||
Window.snapshotShared.connect(snapshotUploaded);
|
sortOrder: 5,
|
||||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
home: Script.resolvePath("html/SnapshotReview.html"),
|
||||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
onOpened: fillImageDataFromPrevious,
|
||||||
Snapshot.snapshotLocationSet.connect(snapshotLocationSet);
|
onMessage: onMessage
|
||||||
|
});
|
||||||
|
|
||||||
Entities.canRezChanged.connect(updatePrintPermissions);
|
Entities.canRezChanged.connect(updatePrintPermissions);
|
||||||
Entities.canRezTmpChanged.connect(updatePrintPermissions);
|
Entities.canRezTmpChanged.connect(updatePrintPermissions);
|
||||||
|
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||||
|
Snapshot.snapshotLocationSet.connect(snapshotLocationSet);
|
||||||
|
Window.snapshotShared.connect(snapshotUploaded);
|
||||||
|
}
|
||||||
|
startup();
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
function shutdown() {
|
||||||
if (buttonConnected) {
|
|
||||||
button.clicked.disconnect(onButtonClicked);
|
|
||||||
buttonConnected = false;
|
|
||||||
}
|
|
||||||
if (tablet) {
|
|
||||||
tablet.removeButton(button);
|
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
|
||||||
}
|
|
||||||
Window.snapshotShared.disconnect(snapshotUploaded);
|
Window.snapshotShared.disconnect(snapshotUploaded);
|
||||||
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
|
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
|
||||||
|
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||||
Entities.canRezChanged.disconnect(updatePrintPermissions);
|
Entities.canRezChanged.disconnect(updatePrintPermissions);
|
||||||
Entities.canRezTmpChanged.disconnect(updatePrintPermissions);
|
Entities.canRezTmpChanged.disconnect(updatePrintPermissions);
|
||||||
});
|
}
|
||||||
|
Script.scriptEnding.connect(shutdown);
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/* jslint vars:true, plusplus:true, forin:true */
|
/* jslint vars:true, plusplus:true, forin:true */
|
||||||
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
/* global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print */
|
/* global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print */
|
||||||
|
|
||||||
//
|
//
|
||||||
// goto.js
|
// tablet-goto.js
|
||||||
// scripts/system/
|
// scripts/system/
|
||||||
//
|
//
|
||||||
// Created by Dante Ruiz on 8 February 2017
|
// Created by Dante Ruiz on 8 February 2017
|
||||||
|
@ -14,8 +15,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
var request = Script.require('request').request;
|
var request = Script.require('request').request;
|
||||||
|
var AppUi = Script.require('appUi');
|
||||||
var DEBUG = false;
|
var DEBUG = false;
|
||||||
function debug() {
|
function debug() {
|
||||||
if (!DEBUG) {
|
if (!DEBUG) {
|
||||||
|
@ -24,57 +25,6 @@
|
||||||
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
||||||
}
|
}
|
||||||
|
|
||||||
var gotoQmlSource = "hifi/tablet/TabletAddressDialog.qml";
|
|
||||||
var buttonName = "GOTO";
|
|
||||||
var onGotoScreen = false;
|
|
||||||
var shouldActivateButton = false;
|
|
||||||
function ignore() { }
|
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
||||||
var NORMAL_ICON = "icons/tablet-icons/goto-i.svg";
|
|
||||||
var NORMAL_ACTIVE = "icons/tablet-icons/goto-a.svg";
|
|
||||||
var WAITING_ICON = "icons/tablet-icons/goto-msg.svg";
|
|
||||||
var button = tablet.addButton({
|
|
||||||
icon: NORMAL_ICON,
|
|
||||||
activeIcon: NORMAL_ACTIVE,
|
|
||||||
text: buttonName,
|
|
||||||
sortOrder: 8
|
|
||||||
});
|
|
||||||
|
|
||||||
function messagesWaiting(isWaiting) {
|
|
||||||
button.editProperties({
|
|
||||||
icon: isWaiting ? WAITING_ICON : NORMAL_ICON
|
|
||||||
// No need for a different activeIcon, because we issue messagesWaiting(false) when the button goes active anyway.
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClicked() {
|
|
||||||
if (onGotoScreen) {
|
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
shouldActivateButton = true;
|
|
||||||
tablet.loadQMLSource(gotoQmlSource);
|
|
||||||
onGotoScreen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
|
||||||
ignore(type);
|
|
||||||
if (url === gotoQmlSource) {
|
|
||||||
onGotoScreen = true;
|
|
||||||
shouldActivateButton = true;
|
|
||||||
button.editProperties({isActive: shouldActivateButton});
|
|
||||||
messagesWaiting(false);
|
|
||||||
} else {
|
|
||||||
shouldActivateButton = false;
|
|
||||||
onGotoScreen = false;
|
|
||||||
button.editProperties({isActive: shouldActivateButton});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
button.clicked.connect(onClicked);
|
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
|
||||||
|
|
||||||
var stories = {}, pingPong = false;
|
var stories = {}, pingPong = false;
|
||||||
function expire(id) {
|
function expire(id) {
|
||||||
var options = {
|
var options = {
|
||||||
|
@ -90,10 +40,12 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var PER_PAGE_DEBUG = 10;
|
||||||
|
var PER_PAGE_NORMAL = 100;
|
||||||
function pollForAnnouncements() {
|
function pollForAnnouncements() {
|
||||||
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
||||||
var actions = 'announcement';
|
var actions = 'announcement';
|
||||||
var count = DEBUG ? 10 : 100;
|
var count = DEBUG ? PER_PAGE_DEBUG : PER_PAGE_NORMAL;
|
||||||
var options = [
|
var options = [
|
||||||
'now=' + new Date().toISOString(),
|
'now=' + new Date().toISOString(),
|
||||||
'include_actions=' + actions,
|
'include_actions=' + actions,
|
||||||
|
@ -117,7 +69,7 @@
|
||||||
var stored = stories[story.id], storedOrNew = stored || story;
|
var stored = stories[story.id], storedOrNew = stored || story;
|
||||||
debug('story exists:', !!stored, storedOrNew);
|
debug('story exists:', !!stored, storedOrNew);
|
||||||
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
||||||
if (storedOrNew.audience == 'for_connections') { // Only expire if we haven't already done so.
|
if (storedOrNew.audience === 'for_connections') { // Only expire if we haven't already done so.
|
||||||
expire(story.id);
|
expire(story.id);
|
||||||
}
|
}
|
||||||
return; // before marking
|
return; // before marking
|
||||||
|
@ -127,7 +79,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stories[story.id] = story;
|
stories[story.id] = story;
|
||||||
var message = story.username + " " + story.action_string + " in " + story.place_name + ". Open GOTO to join them.";
|
var message = story.username + " " + story.action_string + " in " +
|
||||||
|
story.place_name + ". Open GOTO to join them.";
|
||||||
Window.displayAnnouncement(message);
|
Window.displayAnnouncement(message);
|
||||||
didNotify = true;
|
didNotify = true;
|
||||||
});
|
});
|
||||||
|
@ -138,24 +91,42 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (didNotify) {
|
if (didNotify) {
|
||||||
messagesWaiting(true);
|
ui.messagesWaiting(true);
|
||||||
if (HMD.isHandControllerAvailable()) {
|
if (HMD.isHandControllerAvailable()) {
|
||||||
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
||||||
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
||||||
}
|
}
|
||||||
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
||||||
messagesWaiting(false);
|
ui.messagesWaiting(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? 10 : 60) * 1000;
|
var MS_PER_SEC = 1000;
|
||||||
|
var DEBUG_POLL_TIME_SEC = 10;
|
||||||
|
var NORMAL_POLL_TIME_SEC = 60;
|
||||||
|
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? DEBUG_POLL_TIME_SEC : NORMAL_POLL_TIME_SEC) * MS_PER_SEC;
|
||||||
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
function gotoOpened() {
|
||||||
Script.clearInterval(pollTimer);
|
ui.messagesWaiting(false);
|
||||||
button.clicked.disconnect(onClicked);
|
}
|
||||||
tablet.removeButton(button);
|
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var ui;
|
||||||
|
var GOTO_QML_SOURCE = "hifi/tablet/TabletAddressDialog.qml";
|
||||||
|
var BUTTON_NAME = "GOTO";
|
||||||
|
function startup() {
|
||||||
|
ui = new AppUi({
|
||||||
|
buttonName: BUTTON_NAME,
|
||||||
|
sortOrder: 8,
|
||||||
|
onOpened: gotoOpened,
|
||||||
|
home: GOTO_QML_SOURCE
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function shutdown() {
|
||||||
|
Script.clearInterval(pollTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
startup();
|
||||||
|
Script.scriptEnding.connect(shutdown);
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue