Merge branch 'master' into loginInitiative2

This commit is contained in:
Wayne Chen 2018-11-08 11:17:24 -08:00 committed by GitHub
commit e266532888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 816 additions and 241 deletions

View file

@ -216,7 +216,7 @@ void Agent::requestScript() {
}
// make sure this is not a script request for the file scheme
if (scriptURL.scheme() == URL_SCHEME_FILE) {
if (scriptURL.scheme() == HIFI_URL_SCHEME_FILE) {
qWarning() << "Cannot load script for Agent from local filesystem.";
scriptRequestFinished();
return;

View file

@ -55,6 +55,7 @@ Rectangle {
property bool isInstalled;
property bool isUpdating;
property string baseAppURL;
property int currentUpdatesPage: 1;
// Style
color: hifi.colors.white;
Connections {
@ -156,8 +157,14 @@ Rectangle {
break;
}
}
root.availableUpdatesReceived = true;
refreshBuyUI();
if (result.data.updates.length === 0 || root.isUpdating) {
root.availableUpdatesReceived = true;
refreshBuyUI();
} else {
root.currentUpdatesPage++;
Commerce.getAvailableUpdates(root.itemId, currentUpdatesPage)
}
}
}
@ -176,6 +183,7 @@ Rectangle {
root.ownershipStatusReceived = false;
Commerce.alreadyOwned(root.itemId);
root.availableUpdatesReceived = false;
root.currentUpdatesPage = 1;
Commerce.getAvailableUpdates(root.itemId);
itemPreviewImage.source = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/previews/" + itemId + "/thumbnail/hifi-mp-" + itemId + ".jpg";
}
@ -1181,6 +1189,7 @@ Rectangle {
root.ownershipStatusReceived = false;
Commerce.alreadyOwned(root.itemId);
root.availableUpdatesReceived = false;
root.currentUpdatesPage = 1;
Commerce.getAvailableUpdates(root.itemId);
root.balanceReceived = false;
Commerce.balance();

View file

@ -29,7 +29,6 @@ Item {
if (visible) {
Commerce.balance();
transactionHistoryModel.getFirstPage();
Commerce.getAvailableUpdates();
} else {
refreshTimer.stop();
}

View file

@ -0,0 +1,314 @@
//
// TTS.qml
//
// TTS App
//
// Created by Zach Fox on 2018-10-10
// 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
//
import Hifi 1.0 as Hifi
import QtQuick 2.10
import QtQuick.Controls 2.3
import "qrc:////qml//styles-uit" as HifiStylesUit
import "qrc:////qml//controls-uit" as HifiControlsUit
import "qrc:////qml//controls" as HifiControls
Rectangle {
HifiStylesUit.HifiConstants { id: hifi; }
id: root;
// Style
color: hifi.colors.darkGray;
property bool keyboardRaised: false;
//
// TITLE BAR START
//
Item {
id: titleBarContainer;
// Size
width: root.width;
height: 50;
// Anchors
anchors.left: parent.left;
anchors.top: parent.top;
// Title bar text
HifiStylesUit.RalewaySemiBold {
id: titleBarText;
text: "Text-to-Speech";
// Text size
size: hifi.fontSizes.overlayTitle;
// Anchors
anchors.top: parent.top;
anchors.bottom: parent.bottom;
anchors.left: parent.left;
anchors.leftMargin: 16;
width: paintedWidth;
// Style
color: hifi.colors.lightGrayText;
// Alignment
horizontalAlignment: Text.AlignHLeft;
verticalAlignment: Text.AlignVCenter;
}
// Separator
HifiControlsUit.Separator {
anchors.left: parent.left;
anchors.right: parent.right;
anchors.bottom: parent.bottom;
}
}
//
// TITLE BAR END
//
Item {
id: tagButtonContainer;
anchors.top: titleBarContainer.bottom;
anchors.topMargin: 2;
anchors.left: parent.left;
anchors.right: parent.right;
height: 70;
HifiStylesUit.RalewaySemiBold {
id: tagButtonTitle;
text: "Insert Tag:";
// Text size
size: 18;
// Anchors
anchors.top: parent.top;
anchors.left: parent.left;
anchors.right: parent.right;
height: 35;
// Style
color: hifi.colors.lightGrayText;
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
}
HifiControlsUit.Button {
id: pitch10Button;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.none;
colorScheme: hifi.colorSchemes.dark;
anchors.top: tagButtonTitle.bottom;
anchors.left: parent.left;
anchors.leftMargin: 3;
width: parent.width/6 - 6;
height: 30;
text: "Pitch 10";
onClicked: {
messageToSpeak.insert(messageToSpeak.cursorPosition, "<pitch absmiddle='10'/>");
}
}
HifiControlsUit.Button {
id: pitch0Button;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.none;
colorScheme: hifi.colorSchemes.dark;
anchors.top: tagButtonTitle.bottom;
anchors.left: pitch10Button.right;
anchors.leftMargin: 6;
width: parent.width/6 - anchors.leftMargin;
height: 30;
text: "Pitch 0";
onClicked: {
messageToSpeak.insert(messageToSpeak.cursorPosition, "<pitch absmiddle='0'/>");
}
}
HifiControlsUit.Button {
id: pitchNeg10Button;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.none;
colorScheme: hifi.colorSchemes.dark;
anchors.top: tagButtonTitle.bottom;
anchors.left: pitch0Button.right;
anchors.leftMargin: 6;
width: parent.width/6 - anchors.leftMargin;
height: 30;
text: "Pitch -10";
onClicked: {
messageToSpeak.insert(messageToSpeak.cursorPosition, "<pitch absmiddle='-10'/>");
}
}
HifiControlsUit.Button {
id: speed5Button;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.none;
colorScheme: hifi.colorSchemes.dark;
anchors.top: tagButtonTitle.bottom;
anchors.left: pitchNeg10Button.right;
anchors.leftMargin: 6;
width: parent.width/6 - anchors.leftMargin;
height: 30;
text: "Speed 5";
onClicked: {
messageToSpeak.insert(messageToSpeak.cursorPosition, "<rate absspeed='5'/>");
}
}
HifiControlsUit.Button {
id: speed0Button;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.none;
colorScheme: hifi.colorSchemes.dark;
anchors.top: tagButtonTitle.bottom;
anchors.left: speed5Button.right;
anchors.leftMargin: 6;
width: parent.width/6 - anchors.leftMargin;
height: 30;
text: "Speed 0";
onClicked: {
messageToSpeak.insert(messageToSpeak.cursorPosition, "<rate absspeed='0'/>");
}
}
HifiControlsUit.Button {
id: speedNeg10Button;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.none;
colorScheme: hifi.colorSchemes.dark;
anchors.top: tagButtonTitle.bottom;
anchors.left: speed0Button.right;
anchors.leftMargin: 6;
width: parent.width/6 - anchors.leftMargin;
height: 30;
text: "Speed -10";
onClicked: {
messageToSpeak.insert(messageToSpeak.cursorPosition, "<rate absspeed='-10'/>");
}
}
}
Item {
anchors.top: tagButtonContainer.bottom;
anchors.topMargin: 8;
anchors.bottom: keyboardContainer.top;
anchors.bottomMargin: 16;
anchors.left: parent.left;
anchors.leftMargin: 16;
anchors.right: parent.right;
anchors.rightMargin: 16;
TextArea {
id: messageToSpeak;
font.family: "Fira Sans SemiBold";
font.pixelSize: 20;
// Anchors
anchors.top: parent.top;
anchors.left: parent.left;
anchors.right: parent.right;
anchors.bottom: speakButton.top;
anchors.bottomMargin: 8;
// Style
background: Rectangle {
anchors.fill: parent;
color: parent.activeFocus ? hifi.colors.black : hifi.colors.baseGrayShadow;
border.width: parent.activeFocus ? 1 : 0;
border.color: parent.activeFocus ? hifi.colors.primaryHighlight : hifi.colors.textFieldLightBackground;
}
color: hifi.colors.white;
textFormat: TextEdit.PlainText;
wrapMode: TextEdit.Wrap;
activeFocusOnPress: true;
activeFocusOnTab: true;
Keys.onPressed: {
if (event.key == Qt.Key_Return || event.key == Qt.Key_Enter) {
TextToSpeech.speakText(messageToSpeak.text, 480, 10, 24000, 16, true);
event.accepted = true;
}
}
HifiStylesUit.FiraSansRegular {
text: "<i>Input Text to Speak...</i>";
size: 20;
anchors.fill: parent;
anchors.topMargin: 4;
anchors.leftMargin: 4;
color: hifi.colors.lightGrayText;
visible: !parent.activeFocus && messageToSpeak.text === "";
verticalAlignment: Text.AlignTop;
}
}
HifiControlsUit.Button {
id: speakButton;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.blue;
colorScheme: hifi.colorSchemes.dark;
anchors.right: parent.right;
anchors.bottom: parent.bottom;
width: 215;
height: 40;
text: "Speak";
onClicked: {
TextToSpeech.speakText(messageToSpeak.text, 480, 10, 24000, 16, true);
}
}
HifiControlsUit.Button {
id: clearButton;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.white;
colorScheme: hifi.colorSchemes.dark;
anchors.right: speakButton.left;
anchors.rightMargin: 16;
anchors.bottom: parent.bottom;
width: 100;
height: 40;
text: "Clear";
onClicked: {
messageToSpeak.text = "";
}
}
HifiControlsUit.Button {
id: stopButton;
focusPolicy: Qt.NoFocus;
color: hifi.buttons.red;
colorScheme: hifi.colorSchemes.dark;
anchors.right: clearButton.left;
anchors.rightMargin: 16;
anchors.bottom: parent.bottom;
width: 100;
height: 40;
text: "Stop Last";
onClicked: {
TextToSpeech.stopLastSpeech();
}
}
}
Item {
id: keyboardContainer;
z: 998;
visible: keyboard.raised;
property bool punctuationMode: false;
anchors {
bottom: parent.bottom;
left: parent.left;
right: parent.right;
}
HifiControlsUit.Keyboard {
id: keyboard;
raised: HMD.mounted && root.keyboardRaised;
numeric: parent.punctuationMode;
anchors {
bottom: parent.bottom;
left: parent.left;
right: parent.right;
}
}
}
}

View file

@ -186,6 +186,7 @@
#include "scripting/RatesScriptingInterface.h"
#include "scripting/SelectionScriptingInterface.h"
#include "scripting/WalletScriptingInterface.h"
#include "scripting/TTSScriptingInterface.h"
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
#include "SpeechRecognizer.h"
#endif
@ -536,11 +537,11 @@ bool isDomainURL(QUrl url) {
if (url.scheme() == URL_SCHEME_HIFI) {
return true;
}
if (url.scheme() != URL_SCHEME_FILE) {
if (url.scheme() != HIFI_URL_SCHEME_FILE) {
// TODO -- once Octree::readFromURL no-longer takes over the main event-loop, serverless-domain urls can
// be loaded over http(s)
// && url.scheme() != URL_SCHEME_HTTP &&
// url.scheme() != URL_SCHEME_HTTPS
// && url.scheme() != HIFI_URL_SCHEME_HTTP &&
// url.scheme() != HIFI_URL_SCHEME_HTTPS
return false;
}
if (url.path().endsWith(".json", Qt::CaseInsensitive) ||
@ -951,6 +952,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<Ledger>();
DependencyManager::set<Wallet>();
DependencyManager::set<WalletScriptingInterface>();
DependencyManager::set<TTSScriptingInterface>();
DependencyManager::set<FadeEffect>();
DependencyManager::set<ResourceRequestObserver>();
@ -1036,8 +1038,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file
// This is done so as not break previous command line scripts
if (testScriptPath.left(URL_SCHEME_HTTP.length()) == URL_SCHEME_HTTP ||
testScriptPath.left(URL_SCHEME_FTP.length()) == URL_SCHEME_FTP) {
if (testScriptPath.left(HIFI_URL_SCHEME_HTTP.length()) == HIFI_URL_SCHEME_HTTP ||
testScriptPath.left(HIFI_URL_SCHEME_FTP.length()) == HIFI_URL_SCHEME_FTP) {
setProperty(hifi::properties::TEST, QUrl::fromUserInput(testScriptPath));
} else if (QFileInfo(testScriptPath).exists()) {
@ -2903,7 +2905,7 @@ void Application::initializeUi() {
LoginDialog::registerType();
Tooltip::registerType();
UpdateDialog::registerType();
QmlContextCallback callback = [](QQmlContext* context) {
QmlContextCallback commerceCallback = [](QQmlContext* context) {
context->setContextProperty("Commerce", new QmlCommerce());
};
OffscreenQmlSurface::addWhitelistContextHandler({
@ -2929,7 +2931,13 @@ void Application::initializeUi() {
QUrl{ "hifi/dialogs/security/SecurityImageChange.qml" },
QUrl{ "hifi/dialogs/security/SecurityImageModel.qml" },
QUrl{ "hifi/dialogs/security/SecurityImageSelection.qml" },
}, callback);
}, commerceCallback);
QmlContextCallback ttsCallback = [](QQmlContext* context) {
context->setContextProperty("TextToSpeech", DependencyManager::get<TTSScriptingInterface>().data());
};
OffscreenQmlSurface::addWhitelistContextHandler({
QUrl{ "hifi/tts/TTS.qml" }
}, ttsCallback);
qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem");
qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");
qmlRegisterType<WebBrowserSuggestionsEngine>("HifiWeb", 1, 0, "WebBrowserSuggestionsEngine");

View file

@ -122,8 +122,8 @@ void ATPAssetMigrator::loadEntityServerFile() {
QUrl migrationURL = QUrl(migrationURLString);
if (!_ignoredUrls.contains(migrationURL)
&& (migrationURL.scheme() == URL_SCHEME_HTTP || migrationURL.scheme() == URL_SCHEME_HTTPS
|| migrationURL.scheme() == URL_SCHEME_FILE || migrationURL.scheme() == URL_SCHEME_FTP)) {
&& (migrationURL.scheme() == HIFI_URL_SCHEME_HTTP || migrationURL.scheme() == HIFI_URL_SCHEME_HTTPS
|| migrationURL.scheme() == HIFI_URL_SCHEME_FILE || migrationURL.scheme() == HIFI_URL_SCHEME_FTP)) {
if (_pendingReplacements.contains(migrationURL)) {
// we already have a request out for this asset, just store the QJsonValueRef

View file

@ -454,7 +454,7 @@ void Ledger::alreadyOwned(const QString& marketplaceId) {
}
}
void Ledger::getAvailableUpdates(const QString& itemId) {
void Ledger::getAvailableUpdates(const QString& itemId, const int& pageNumber, const int& itemsPerPage) {
auto wallet = DependencyManager::get<Wallet>();
QString endpoint = "available_updates";
QJsonObject request;
@ -462,6 +462,8 @@ void Ledger::getAvailableUpdates(const QString& itemId) {
if (!itemId.isEmpty()) {
request["marketplace_item_id"] = itemId;
}
request["per_page"] = itemsPerPage;
request["page"] = pageNumber;
send(endpoint, "availableUpdatesSuccess", "availableUpdatesFailure", QNetworkAccessManager::PutOperation, AccountManagerAuth::Required, request);
}

View file

@ -37,7 +37,7 @@ public:
void transferAssetToNode(const QString& hfc_key, const QString& nodeID, const QString& certificateID, const int& amount, const QString& optionalMessage);
void transferAssetToUsername(const QString& hfc_key, const QString& username, const QString& certificateID, const int& amount, const QString& optionalMessage);
void alreadyOwned(const QString& marketplaceId);
void getAvailableUpdates(const QString& itemId = "");
void getAvailableUpdates(const QString& itemId = "", const int& pageNumber = 1, const int& itemsPerPage = 10);
void updateItem(const QString& hfc_key, const QString& certificate_id);
enum CertificateStatus {

View file

@ -441,9 +441,9 @@ bool QmlCommerce::openApp(const QString& itemHref) {
return true;
}
void QmlCommerce::getAvailableUpdates(const QString& itemId) {
void QmlCommerce::getAvailableUpdates(const QString& itemId, const int& pageNumber, const int& itemsPerPage) {
auto ledger = DependencyManager::get<Ledger>();
ledger->getAvailableUpdates(itemId);
ledger->getAvailableUpdates(itemId, pageNumber, itemsPerPage);
}
void QmlCommerce::updateItem(const QString& certificateId) {

View file

@ -92,7 +92,7 @@ protected:
Q_INVOKABLE bool uninstallApp(const QString& appHref);
Q_INVOKABLE bool openApp(const QString& appHref);
Q_INVOKABLE void getAvailableUpdates(const QString& itemId = "");
Q_INVOKABLE void getAvailableUpdates(const QString& itemId = "", const int& pageNumber = 1, const int& itemsPerPage = 10);
Q_INVOKABLE void updateItem(const QString& certificateId);
private:

View file

@ -0,0 +1,163 @@
//
// TTSScriptingInterface.cpp
// libraries/audio-client/src/scripting
//
// Created by Zach Fox on 2018-10-10.
// 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 "TTSScriptingInterface.h"
#include "avatar/AvatarManager.h"
TTSScriptingInterface::TTSScriptingInterface() {
#ifdef WIN32
//
// Create text to speech engine
//
HRESULT hr = m_tts.CoCreateInstance(CLSID_SpVoice);
if (FAILED(hr)) {
qDebug() << "Text-to-speech engine creation failed.";
}
//
// Get token corresponding to default voice
//
hr = SpGetDefaultTokenFromCategoryId(SPCAT_VOICES, &m_voiceToken, FALSE);
if (FAILED(hr)) {
qDebug() << "Can't get default voice token.";
}
//
// Set default voice
//
hr = m_tts->SetVoice(m_voiceToken);
if (FAILED(hr)) {
qDebug() << "Can't set default voice.";
}
_lastSoundAudioInjectorUpdateTimer.setSingleShot(true);
connect(&_lastSoundAudioInjectorUpdateTimer, &QTimer::timeout, this, &TTSScriptingInterface::updateLastSoundAudioInjector);
#endif
}
TTSScriptingInterface::~TTSScriptingInterface() {
}
#ifdef WIN32
class ReleaseOnExit {
public:
ReleaseOnExit(IUnknown* p) : m_p(p) {}
~ReleaseOnExit() {
if (m_p) {
m_p->Release();
}
}
private:
IUnknown* m_p;
};
#endif
const int INJECTOR_INTERVAL_MS = 100;
void TTSScriptingInterface::updateLastSoundAudioInjector() {
if (_lastSoundAudioInjector) {
AudioInjectorOptions options;
options.position = DependencyManager::get<AvatarManager>()->getMyAvatarPosition();
_lastSoundAudioInjector->setOptions(options);
_lastSoundAudioInjectorUpdateTimer.start(INJECTOR_INTERVAL_MS);
}
}
void TTSScriptingInterface::speakText(const QString& textToSpeak) {
#ifdef WIN32
WAVEFORMATEX fmt;
fmt.wFormatTag = WAVE_FORMAT_PCM;
fmt.nSamplesPerSec = AudioConstants::SAMPLE_RATE;
fmt.wBitsPerSample = 16;
fmt.nChannels = 1;
fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8;
fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign;
fmt.cbSize = 0;
IStream* pStream = NULL;
ISpStream* pSpStream = nullptr;
HRESULT hr = CoCreateInstance(CLSID_SpStream, nullptr, CLSCTX_ALL, __uuidof(ISpStream), (void**)&pSpStream);
if (FAILED(hr)) {
qDebug() << "CoCreateInstance failed.";
}
ReleaseOnExit rSpStream(pSpStream);
pStream = SHCreateMemStream(NULL, 0);
if (nullptr == pStream) {
qDebug() << "SHCreateMemStream failed.";
}
hr = pSpStream->SetBaseStream(pStream, SPDFID_WaveFormatEx, &fmt);
if (FAILED(hr)) {
qDebug() << "Can't set base stream.";
}
hr = m_tts->SetOutput(pSpStream, true);
if (FAILED(hr)) {
qDebug() << "Can't set output stream.";
}
ReleaseOnExit rStream(pStream);
ULONG streamNumber;
hr = m_tts->Speak(reinterpret_cast<LPCWSTR>(textToSpeak.utf16()), SPF_IS_XML | SPF_ASYNC | SPF_PURGEBEFORESPEAK,
&streamNumber);
if (FAILED(hr)) {
qDebug() << "Speak failed.";
}
m_tts->WaitUntilDone(-1);
hr = pSpStream->GetBaseStream(&pStream);
if (FAILED(hr)) {
qDebug() << "Couldn't get base stream.";
}
hr = IStream_Reset(pStream);
if (FAILED(hr)) {
qDebug() << "Couldn't reset stream.";
}
ULARGE_INTEGER StreamSize;
StreamSize.LowPart = 0;
hr = IStream_Size(pStream, &StreamSize);
DWORD dwSize = StreamSize.QuadPart;
_lastSoundByteArray.resize(dwSize);
hr = IStream_Read(pStream, _lastSoundByteArray.data(), dwSize);
if (FAILED(hr)) {
qDebug() << "Couldn't read from stream.";
}
AudioInjectorOptions options;
options.position = DependencyManager::get<AvatarManager>()->getMyAvatarPosition();
if (_lastSoundAudioInjector) {
_lastSoundAudioInjector->stop();
_lastSoundAudioInjectorUpdateTimer.stop();
}
_lastSoundAudioInjector = AudioInjector::playSoundAndDelete(_lastSoundByteArray, options);
_lastSoundAudioInjectorUpdateTimer.start(INJECTOR_INTERVAL_MS);
#else
qDebug() << "Text-to-Speech isn't currently supported on non-Windows platforms.";
#endif
}
void TTSScriptingInterface::stopLastSpeech() {
if (_lastSoundAudioInjector) {
_lastSoundAudioInjector->stop();
_lastSoundAudioInjector = NULL;
}
}

View file

@ -0,0 +1,88 @@
// TTSScriptingInterface.h
// libraries/audio-client/src/scripting
//
// Created by Zach Fox on 2018-10-10.
// 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
//
#ifndef hifi_SpeechScriptingInterface_h
#define hifi_SpeechScriptingInterface_h
#include <QtCore/QObject>
#include <QTimer>
#include <DependencyManager.h>
#ifdef WIN32
#pragma warning(disable : 4996)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <sapi.h> // SAPI
#include <sphelper.h> // SAPI Helper
#endif
#include <AudioInjector.h>
#include <AudioConstants.h>
class TTSScriptingInterface : public QObject, public Dependency {
Q_OBJECT
public:
TTSScriptingInterface();
~TTSScriptingInterface();
Q_INVOKABLE void speakText(const QString& textToSpeak);
Q_INVOKABLE void stopLastSpeech();
private:
#ifdef WIN32
class CComAutoInit {
public:
// Initializes COM using CoInitialize.
// On failure, signals error using AtlThrow.
CComAutoInit() {
HRESULT hr = ::CoInitialize(NULL);
if (FAILED(hr)) {
ATLTRACE(TEXT("CoInitialize() failed in CComAutoInit constructor (hr=0x%08X).\n"), hr);
AtlThrow(hr);
}
}
// Initializes COM using CoInitializeEx.
// On failure, signals error using AtlThrow.
explicit CComAutoInit(__in DWORD dwCoInit) {
HRESULT hr = ::CoInitializeEx(NULL, dwCoInit);
if (FAILED(hr)) {
ATLTRACE(TEXT("CoInitializeEx() failed in CComAutoInit constructor (hr=0x%08X).\n"), hr);
AtlThrow(hr);
}
}
// Uninitializes COM using CoUninitialize.
~CComAutoInit() { ::CoUninitialize(); }
//
// Ban copy
//
private:
CComAutoInit(const CComAutoInit&);
};
// COM initialization and cleanup (must precede other COM related data members)
CComAutoInit m_comInit;
// Text to speech engine
CComPtr<ISpVoice> m_tts;
// Default voice token
CComPtr<ISpObjectToken> m_voiceToken;
#endif
QByteArray _lastSoundByteArray;
AudioInjectorPointer _lastSoundAudioInjector;
QTimer _lastSoundAudioInjectorUpdateTimer;
void updateLastSoundAudioInjector();
};
#endif // hifi_SpeechScriptingInterface_h

View file

@ -290,6 +290,7 @@ void Base3DOverlay::locationChanged(bool tellPhysics) {
notifyRenderVariableChange();
}
// FIXME: Overlays shouldn't be deleted when their parents are
void Base3DOverlay::parentDeleted() {
qApp->getOverlays().deleteOverlay(getOverlayID());
}

View file

@ -59,8 +59,6 @@ public:
void setIsGrabbable(bool value) { _isGrabbable = value; }
virtual void setIsVisibleInSecondaryCamera(bool value) { _isVisibleInSecondaryCamera = value; }
virtual AABox getBounds() const override = 0;
void update(float deltatime) override;
void notifyRenderVariableChange() const;

View file

@ -60,6 +60,8 @@ ModelOverlay::ModelOverlay(const ModelOverlay* modelOverlay) :
}
void ModelOverlay::update(float deltatime) {
Base3DOverlay::update(deltatime);
if (_updateModel) {
_updateModel = false;
_model->setSnapModelToCenter(true);

View file

@ -247,7 +247,7 @@ void Overlay::removeMaterial(graphics::MaterialPointer material, const std::stri
}
render::ItemKey Overlay::getKey() {
auto builder = render::ItemKey::Builder().withTypeShape();
auto builder = render::ItemKey::Builder().withTypeShape().withTypeMeta();
builder.withViewSpace();
builder.withLayer(render::hifi::LAYER_2D);

View file

@ -20,11 +20,9 @@ Volume3DOverlay::Volume3DOverlay(const Volume3DOverlay* volume3DOverlay) :
}
AABox Volume3DOverlay::getBounds() const {
auto extents = Extents{_localBoundingBox};
extents.rotate(getWorldOrientation());
extents.shiftBy(getWorldPosition());
return AABox(extents);
AABox bounds = _localBoundingBox;
bounds.transform(getTransform());
return bounds;
}
void Volume3DOverlay::setDimensions(const glm::vec3& value) {
@ -49,15 +47,7 @@ void Volume3DOverlay::setProperties(const QVariantMap& properties) {
glm::vec3 scale = vec3FromVariant(dimensions);
// don't allow a zero or negative dimension component to reach the renderTransform
const float MIN_DIMENSION = 0.0001f;
if (scale.x < MIN_DIMENSION) {
scale.x = MIN_DIMENSION;
}
if (scale.y < MIN_DIMENSION) {
scale.y = MIN_DIMENSION;
}
if (scale.z < MIN_DIMENSION) {
scale.z = MIN_DIMENSION;
}
scale = glm::max(scale, MIN_DIMENSION);
setDimensions(scale);
}
}

View file

@ -24,7 +24,6 @@ public:
virtual AABox getBounds() const override;
const glm::vec3& getDimensions() const { return _localBoundingBox.getDimensions(); }
void setDimensions(float value) { setDimensions(glm::vec3(value)); }
void setDimensions(const glm::vec3& value);
void setProperties(const QVariantMap& properties) override;
@ -37,7 +36,7 @@ public:
protected:
// Centered local bounding box
AABox _localBoundingBox{ vec3(0.0f), 1.0f };
AABox _localBoundingBox { vec3(-0.5), 1.0f };
Transform evalRenderTransform() override;
};

View file

@ -54,7 +54,7 @@ WebEntityRenderer::ContentType WebEntityRenderer::getContentType(const QString&
const QUrl url(urlString);
auto scheme = url.scheme();
if (scheme == URL_SCHEME_ABOUT || scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS ||
if (scheme == HIFI_URL_SCHEME_ABOUT || scheme == HIFI_URL_SCHEME_HTTP || scheme == HIFI_URL_SCHEME_HTTPS ||
urlString.toLower().endsWith(".htm") || urlString.toLower().endsWith(".html")) {
return ContentType::HtmlContent;
}

View file

@ -183,7 +183,7 @@ void EntityEditFilters::addFilter(EntityItemID entityID, QString filterURL) {
}
// The following should be abstracted out for use in Agent.cpp (and maybe later AvatarMixer.cpp)
if (scriptURL.scheme().isEmpty() || (scriptURL.scheme() == URL_SCHEME_FILE)) {
if (scriptURL.scheme().isEmpty() || (scriptURL.scheme() == HIFI_URL_SCHEME_FILE)) {
qWarning() << "Cannot load script from local filesystem, because assignment may be on a different computer.";
scriptRequestFinished(entityID);
return;

View file

@ -2767,9 +2767,11 @@ bool EntityTree::readFromMap(QVariantMap& map) {
success = false;
}
const QUuid& cloneOriginID = entity->getCloneOriginID();
if (!cloneOriginID.isNull()) {
cloneIDs[cloneOriginID].push_back(entity->getEntityItemID());
if (entity) {
const QUuid& cloneOriginID = entity->getCloneOriginID();
if (!cloneOriginID.isNull()) {
cloneIDs[cloneOriginID].push_back(entity->getEntityItemID());
}
}
}

View file

@ -329,7 +329,7 @@ _maxNumPixels(100)
static bool isLocalUrl(const QUrl& url) {
auto scheme = url.scheme();
return (scheme == URL_SCHEME_FILE || scheme == URL_SCHEME_QRC || scheme == RESOURCE_SCHEME);
return (scheme == HIFI_URL_SCHEME_FILE || scheme == URL_SCHEME_QRC || scheme == RESOURCE_SCHEME);
}
NetworkTexture::NetworkTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels) :
@ -503,7 +503,7 @@ void NetworkTexture::handleLocalRequestCompleted() {
void NetworkTexture::makeLocalRequest() {
const QString scheme = _activeUrl.scheme();
QString path;
if (scheme == URL_SCHEME_FILE) {
if (scheme == HIFI_URL_SCHEME_FILE) {
path = PathUtils::expandToLocalDataAbsolutePath(_activeUrl).toLocalFile();
} else {
path = ":" + _activeUrl.path();

View file

@ -155,12 +155,12 @@ void AddressManager::goForward() {
void AddressManager::storeCurrentAddress() {
auto url = currentAddress();
if (url.scheme() == URL_SCHEME_FILE ||
if (url.scheme() == HIFI_URL_SCHEME_FILE ||
(url.scheme() == URL_SCHEME_HIFI && !url.host().isEmpty())) {
// TODO -- once Octree::readFromURL no-longer takes over the main event-loop, serverless-domain urls can
// be loaded over http(s)
// url.scheme() == URL_SCHEME_HTTP ||
// url.scheme() == URL_SCHEME_HTTPS ||
// url.scheme() == HIFI_URL_SCHEME_HTTP ||
// url.scheme() == HIFI_URL_SCHEME_HTTPS ||
bool isInErrorState = DependencyManager::get<NodeList>()->getDomainHandler().isInErrorState();
if (isConnected()) {
if (isInErrorState) {
@ -331,11 +331,11 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
emit lookupResultsFinished();
return true;
} else if (lookupUrl.scheme() == URL_SCHEME_FILE) {
} else if (lookupUrl.scheme() == HIFI_URL_SCHEME_FILE) {
// TODO -- once Octree::readFromURL no-longer takes over the main event-loop, serverless-domain urls can
// be loaded over http(s)
// lookupUrl.scheme() == URL_SCHEME_HTTP ||
// lookupUrl.scheme() == URL_SCHEME_HTTPS ||
// lookupUrl.scheme() == HIFI_URL_SCHEME_HTTPS ||
// TODO once a file can return a connection refusal if there were to be some kind of load error, we'd
// need to store the previous domain tried in _lastVisitedURL. For now , do not store it.

View file

@ -196,7 +196,7 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
_sockAddr.clear();
// if this is a file URL we need to see if it has a ~ for us to expand
if (domainURL.scheme() == URL_SCHEME_FILE) {
if (domainURL.scheme() == HIFI_URL_SCHEME_FILE) {
domainURL = PathUtils::expandToLocalDataAbsolutePath(domainURL);
}
}

View file

@ -30,14 +30,14 @@ namespace NetworkingConstants {
QUrl METAVERSE_SERVER_URL();
}
const QString URL_SCHEME_ABOUT = "about";
const QString HIFI_URL_SCHEME_ABOUT = "about";
const QString URL_SCHEME_HIFI = "hifi";
const QString URL_SCHEME_HIFIAPP = "hifiapp";
const QString URL_SCHEME_QRC = "qrc";
const QString URL_SCHEME_FILE = "file";
const QString URL_SCHEME_HTTP = "http";
const QString URL_SCHEME_HTTPS = "https";
const QString URL_SCHEME_FTP = "ftp";
const QString HIFI_URL_SCHEME_FILE = "file";
const QString HIFI_URL_SCHEME_HTTP = "http";
const QString HIFI_URL_SCHEME_HTTPS = "https";
const QString HIFI_URL_SCHEME_FTP = "ftp";
const QString URL_SCHEME_ATP = "atp";
#endif // hifi_NetworkingConstants_h

View file

@ -118,7 +118,7 @@ QSharedPointer<Resource> ResourceCacheSharedItems::getHighestPendingRequest() {
// Check load priority
float priority = resource->getLoadPriority();
bool isFile = resource->getURL().scheme() == URL_SCHEME_FILE;
bool isFile = resource->getURL().scheme() == HIFI_URL_SCHEME_FILE;
if (priority >= highestPriority && (isFile || !currentHighestIsFile)) {
highestPriority = priority;
highestIndex = i;

View file

@ -82,10 +82,10 @@ const QSet<QString>& getKnownUrls() {
static std::once_flag once;
std::call_once(once, [] {
knownUrls.insert(URL_SCHEME_QRC);
knownUrls.insert(URL_SCHEME_FILE);
knownUrls.insert(URL_SCHEME_HTTP);
knownUrls.insert(URL_SCHEME_HTTPS);
knownUrls.insert(URL_SCHEME_FTP);
knownUrls.insert(HIFI_URL_SCHEME_FILE);
knownUrls.insert(HIFI_URL_SCHEME_HTTP);
knownUrls.insert(HIFI_URL_SCHEME_HTTPS);
knownUrls.insert(HIFI_URL_SCHEME_FTP);
knownUrls.insert(URL_SCHEME_ATP);
});
return knownUrls;
@ -97,7 +97,7 @@ QUrl ResourceManager::normalizeURL(const QUrl& originalUrl) {
if (!getKnownUrls().contains(scheme)) {
// check the degenerative file case: on windows we can often have urls of the form c:/filename
// this checks for and works around that case.
QUrl urlWithFileScheme{ URL_SCHEME_FILE + ":///" + url.toString() };
QUrl urlWithFileScheme{ HIFI_URL_SCHEME_FILE + ":///" + url.toString() };
if (!urlWithFileScheme.toLocalFile().isEmpty()) {
return urlWithFileScheme;
}
@ -124,9 +124,9 @@ ResourceRequest* ResourceManager::createResourceRequest(
ResourceRequest* request = nullptr;
if (scheme == URL_SCHEME_FILE || scheme == URL_SCHEME_QRC) {
if (scheme == HIFI_URL_SCHEME_FILE || scheme == URL_SCHEME_QRC) {
request = new FileResourceRequest(normalizedURL, isObservable, callerId, extra);
} else if (scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP) {
} else if (scheme == HIFI_URL_SCHEME_HTTP || scheme == HIFI_URL_SCHEME_HTTPS || scheme == HIFI_URL_SCHEME_FTP) {
request = new HTTPResourceRequest(normalizedURL, isObservable, callerId, extra);
} else if (scheme == URL_SCHEME_ATP) {
if (!_atpSupportEnabled) {
@ -149,10 +149,10 @@ ResourceRequest* ResourceManager::createResourceRequest(
bool ResourceManager::resourceExists(const QUrl& url) {
auto scheme = url.scheme();
if (scheme == URL_SCHEME_FILE) {
if (scheme == HIFI_URL_SCHEME_FILE) {
QFileInfo file{ url.toString() };
return file.exists();
} else if (scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP) {
} else if (scheme == HIFI_URL_SCHEME_HTTP || scheme == HIFI_URL_SCHEME_HTTPS || scheme == HIFI_URL_SCHEME_FTP) {
auto& networkAccessManager = NetworkAccessManager::getInstance();
QNetworkRequest request{ url };

View file

@ -305,15 +305,16 @@ bool ObjectMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine*
}
return true;
}
}
if (_shape == newShape) {
// the shape didn't actually change, so we clear the DIRTY_SHAPE flag
flags &= ~Simulation::DIRTY_SHAPE;
// and clear the reference we just created
getShapeManager()->releaseShape(_shape);
} else {
_body->setCollisionShape(const_cast<btCollisionShape*>(newShape));
setShape(newShape);
if (_shape == newShape) {
// the shape didn't actually change, so we clear the DIRTY_SHAPE flag
flags &= ~Simulation::DIRTY_SHAPE;
// and clear the reference we just created
getShapeManager()->releaseShape(_shape);
} else {
_body->setCollisionShape(const_cast<btCollisionShape*>(newShape));
setShape(newShape);
}
}
}
if (flags & EASY_DIRTY_PHYSICS_FLAGS) {

View file

@ -289,6 +289,12 @@ void PhysicsEngine::processTransaction(PhysicsEngine::Transaction& transaction)
bumpAndPruneContacts(object);
btRigidBody* body = object->getRigidBody();
if (body) {
if (body->isStaticObject() && _activeStaticBodies.size() > 0) {
std::set<btRigidBody*>::iterator itr = _activeStaticBodies.find(body);
if (itr != _activeStaticBodies.end()) {
_activeStaticBodies.erase(itr);
}
}
removeDynamicsForBody(body);
_dynamicsWorld->removeRigidBody(body);

View file

@ -205,7 +205,7 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext,
if (!srcFilter.selectsNothing()) {
auto filter = render::ItemFilter::Builder(srcFilter).withoutSubMetaCulled().build();
// Now get the bound, and
// Now get the bound, and
// filter individually against the _filter
// visibility cull if partially selected ( octree cell contianing it was partial)
// distance cull if was a subcell item ( octree cell is way bigger than the item bound itself, so now need to test per item)

View file

@ -279,11 +279,27 @@ Rectangle {
}
}
Separator {}
HifiControls.Button {
text: "Engine"
// activeFocusOnPress: false
onClicked: {
sendToScript({method: "openEngineView"});
Row {
HifiControls.Button {
text: "Engine"
// activeFocusOnPress: false
onClicked: {
sendToScript({method: "openEngineView"});
}
}
HifiControls.Button {
text: "LOD"
// activeFocusOnPress: false
onClicked: {
sendToScript({method: "openEngineLODView"});
}
}
HifiControls.Button {
text: "Cull"
// activeFocusOnPress: false
onClicked: {
sendToScript({method: "openCullInspectorView"});
}
}
}
}

View file

@ -11,122 +11,131 @@
//
(function() {
var TABLET_BUTTON_NAME = "LUCI";
var QMLAPP_URL = Script.resolvePath("./deferredLighting.qml");
var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg");
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg");
var onLuciScreen = false;
function onClicked() {
if (onLuciScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
text: TABLET_BUTTON_NAME,
icon: ICON_URL,
activeIcon: ACTIVE_ICON_URL
});
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 onScreenChanged(type, url) {
if (url === QMLAPP_URL) {
onLuciScreen = true;
} else {
onLuciScreen = false;
}
button.editProperties({isActive: onLuciScreen});
wireEventBridge(onLuciScreen);
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
var AppUi = Script.require('appUi');
var moveDebugCursor = false;
Controller.mousePressEvent.connect(function (e) {
var onMousePressEvent = function (e) {
if (e.isMiddleButton) {
moveDebugCursor = true;
setDebugCursor(e.x, e.y);
}
});
Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; });
Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); });
};
Controller.mousePressEvent.connect(onMousePressEvent);
var onMouseReleaseEvent = function () {
moveDebugCursor = false;
};
Controller.mouseReleaseEvent.connect(onMouseReleaseEvent);
var onMouseMoveEvent = function (e) {
if (moveDebugCursor) {
setDebugCursor(e.x, e.y);
}
};
Controller.mouseMoveEvent.connect(onMouseMoveEvent);
function setDebugCursor(x, y) {
nx = 2.0 * (x / Window.innerWidth) - 1.0;
ny = 1.0 - 2.0 * ((y) / (Window.innerHeight));
var nx = 2.0 * (x / Window.innerWidth) - 1.0;
var ny = 1.0 - 2.0 * ((y) / (Window.innerHeight));
Render.getConfig("RenderMainView").getConfig("DebugDeferredBuffer").size = { x: nx, y: ny, z: 1.0, w: 1.0 };
Render.getConfig("RenderMainView").getConfig("DebugDeferredBuffer").size = { x: nx, y: ny, z: 1.0, w: 1.0 };
}
function Page(title, qmlurl, width, height) {
this.title = title;
this.qml = qmlurl;
this.width = width;
this.height = height;
this.window;
print("Page: New Page:" + JSON.stringify(this));
}
Page.prototype.killView = function () {
print("Page: Kill window for page:" + JSON.stringify(this));
if (this.window) {
print("Page: Kill window for page:" + this.title);
//this.window.closed.disconnect(function () {
// this.killView();
//});
this.window.close();
this.window = false;
}
};
Page.prototype.createView = function () {
var that = this;
if (!this.window) {
print("Page: New window for page:" + this.title);
this.window = Desktop.createWindow(Script.resolvePath(this.qml), {
title: this.title,
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: this.width, y: this.height}
});
this.window.closed.connect(function () {
that.killView();
});
}
};
var Pages = function () {
this._pages = {};
};
Pages.prototype.addPage = function (command, title, qmlurl, width, height) {
this._pages[command] = new Page(title, qmlurl, width, height);
};
Pages.prototype.open = function (command) {
print("Pages: command = " + command);
if (!this._pages[command]) {
print("Pages: unknown command = " + command);
return;
}
this._pages[command].createView();
};
Pages.prototype.clear = function () {
for (var p in this._pages) {
print("Pages: kill page: " + p);
this._pages[p].killView();
delete this._pages[p];
}
this._pages = {};
};
var pages = new Pages();
pages.addPage('openEngineView', 'Render Engine', 'engineInspector.qml', 300, 400);
pages.addPage('openEngineLODView', 'Render LOD', 'lod.qml', 300, 400);
pages.addPage('openCullInspectorView', 'Cull Inspector', 'culling.qml', 300, 400);
function fromQml(message) {
switch (message.method) {
case "openEngineView":
openEngineTaskView();
break;
}
if (pages.open(message.method)) {
return;
}
}
var engineInspectorView = null
function openEngineTaskView() {
if (engineInspectorView == null) {
var qml = Script.resolvePath('engineInspector.qml');
var window = new OverlayWindow({
title: 'Render Engine',
source: qml,
width: 300,
height: 400
});
window.setPosition(200, 50);
engineInspectorView = window
window.closed.connect(function() { engineInspectorView = null; });
} else {
engineInspectorView.setPosition(200, 50);
}
var ui;
function startup() {
ui = new AppUi({
buttonName: "LUCI",
home: Script.resolvePath("deferredLighting.qml"),
additionalAppScreens: Script.resolvePath("engineInspector.qml"),
onMessage: fromQml,
normalButton: Script.resolvePath("../../../system/assets/images/luci-i.svg"),
activeButton: Script.resolvePath("../../../system/assets/images/luci-a.svg")
});
}
startup();
Script.scriptEnding.connect(function () {
if (onLuciScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
if (engineInspectorView !== null) {
engineInspectorView.close()
}
Controller.mousePressEvent.disconnect(onMousePressEvent);
Controller.mouseReleaseEvent.disconnect(onMouseReleaseEvent);
Controller.mouseMoveEvent.disconnect(onMouseMoveEvent);
pages.clear();
// killEngineInspectorView();
// killCullInspectorView();
// killEngineLODWindow();
});
}());
}());

View file

@ -196,12 +196,6 @@
"particleRadius": {
"tooltip": "The size of each particle."
},
"radiusStart": {
"tooltip": ""
},
"radiusFinish": {
"tooltip": ""
},
"radiusSpread": {
"tooltip": "The spread in size that each particle is given, resulting in a variety of sizes."
},
@ -215,12 +209,6 @@
"alpha": {
"tooltip": "The alpha of each particle."
},
"alphaStart": {
"tooltip": ""
},
"alphaFinish": {
"tooltip": ""
},
"alphaSpread": {
"tooltip": "The spread in alpha that each particle is given, resulting in a variety of alphas."
},
@ -233,12 +221,6 @@
"particleSpin": {
"tooltip": "The spin of each particle in the system."
},
"spinStart": {
"tooltip": ""
},
"spinFinish": {
"tooltip": ""
},
"spinSpread": {
"tooltip": "The spread in spin that each particle is given, resulting in a variety of spins."
},
@ -248,15 +230,9 @@
"polarStart": {
"tooltip": "The angle in deg at which particles are emitted. Starts in the entity's -z direction, and rotates around its y axis."
},
"polarFinish": {
"tooltip": ""
},
"azimuthStart": {
"tooltip": "The angle in deg at which particles are emitted. Starts in the entity's -z direction, and rotates around its y axis."
},
"azimuthFinish": {
"tooltip": ""
},
"lightColor": {
"tooltip": "The color of the light emitted.",
"jsPropertyName": "color"

View file

@ -278,7 +278,7 @@ const DEFAULT_ENTITY_PROPERTIES = {
All: {
description: "",
rotation: { x: 0, y: 0, z: 0, w: 1 },
collidesWith: "static,dynamic,kinematic,otherAvatar",
collidesWith: "static,dynamic,kinematic,otherAvatar,myAvatar",
collisionSoundURL: "",
cloneable: false,
ignoreIK: true,
@ -484,23 +484,28 @@ var toolBar = (function () {
originalProperties[key] = newProperties[key];
}
}
function createNewEntity(properties) {
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
function createNewEntity(requestedProperties) {
var dimensions = requestedProperties.dimensions ? requestedProperties.dimensions : DEFAULT_DIMENSIONS;
var position = getPositionToCreateEntity();
var entityID = null;
var properties = {};
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES.All);
var type = properties.type;
var type = requestedProperties.type;
if (type == "Box" || type == "Sphere") {
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES.Shape);
} else if (type == "Image") {
properties.type = "Model";
requestedProperties.type = "Model";
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES.Image);
} else {
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES[type]);
}
// We apply the requested properties first so that they take priority over any default properties.
applyProperties(properties, requestedProperties);
if (position !== null && position !== undefined) {
var direction;
@ -845,41 +850,18 @@ var toolBar = (function () {
addButton("newCubeButton", function () {
createNewEntity({
type: "Box",
dimensions: DEFAULT_DIMENSIONS,
color: {
red: 255,
green: 0,
blue: 0
}
});
});
addButton("newSphereButton", function () {
createNewEntity({
type: "Sphere",
dimensions: DEFAULT_DIMENSIONS,
color: {
red: 255,
green: 0,
blue: 0
}
});
});
addButton("newLightButton", function () {
createNewEntity({
type: "Light",
isSpotlight: false,
color: {
red: 150,
green: 150,
blue: 150
},
constantAttenuation: 1,
linearAttenuation: 0,
quadraticAttenuation: 0,
exponent: 0,
cutoff: 180 // in degrees
});
});
@ -2490,6 +2472,13 @@ var PropertiesTool = function (opts) {
}
};
HMD.displayModeChanged.connect(function() {
emitScriptEvent({
type: 'hmdActiveChanged',
hmdActive: HMD.active,
});
});
createToolsWindow.webEventReceived.addListener(this, onWebEventReceived);
webView.webEventReceived.connect(onWebEventReceived);

View file

@ -1598,7 +1598,7 @@ input.rename-entity {
padding-left: 2px;
}
.createAppTooltip {
.create-app-tooltip {
position: absolute;
background: #6a6a6a;
border: 1px solid black;
@ -1607,17 +1607,16 @@ input.rename-entity {
padding: 5px;
}
.createAppTooltip .createAppTooltipDescription {
.create-app-tooltip .create-app-tooltip-description {
font-size: 12px;
font-style: italic;
color: #ffffff;
}
.createAppTooltip .createAppTooltipJSAttribute {
.create-app-tooltip .create-app-tooltip-js-attribute {
font-family: Raleway-SemiBold;
font-size: 11px;
color: #000000;
bottom: 0;
margin-top: 5px;
}

View file

@ -58,15 +58,15 @@ CreateAppTooltip.prototype = {
if (!TOOLTIP_DEBUG) {
return;
}
tooltipData = {tooltip: 'PLEASE SET THIS TOOLTIP'};
tooltipData = { tooltip: 'PLEASE SET THIS TOOLTIP' };
}
let elementRect = element.getBoundingClientRect();
let elTip = document.createElement("div");
elTip.className = "createAppTooltip";
elTip.className = "create-app-tooltip";
let elTipDescription = document.createElement("div");
elTipDescription.className = "createAppTooltipDescription";
elTipDescription.className = "create-app-tooltip-description";
elTipDescription.innerText = tooltipData.tooltip;
elTip.appendChild(elTipDescription);
@ -77,7 +77,7 @@ CreateAppTooltip.prototype = {
if (!tooltipData.skipJSProperty) {
let elTipJSAttribute = document.createElement("div");
elTipJSAttribute.className = "createAppTooltipJSAttribute";
elTipJSAttribute.className = "create-app-tooltip-js-attribute";
elTipJSAttribute.innerText = `JS Attribute: ${jsAttribute}`;
elTip.appendChild(elTipJSAttribute);
}
@ -93,7 +93,7 @@ CreateAppTooltip.prototype = {
// show above when otherwise out of bounds
elTip.style.top = elementTop - CREATE_APP_TOOLTIP_OFFSET - elTip.clientHeight;
} else {
// show tooltip on below by default
// show tooltip below by default
elTip.style.top = desiredTooltipTop;
}
if ((window.innerWidth + window.pageXOffset) < (desiredTooltipLeft + elTip.clientWidth)) {

View file

@ -3165,8 +3165,13 @@ function loaded() {
} else if (data.type === 'tooltipsReply') {
createAppTooltip.setIsEnabled(!data.hmdActive);
createAppTooltip.setTooltipData(data.tooltips);
} else if (data.type === 'hmdActiveChanged') {
createAppTooltip.setIsEnabled(!data.hmdActive);
}
});
// Request tooltips as soon as we can process a reply:
EventBridge.emitWebEvent(JSON.stringify({ type: 'tooltipsRequest' }));
}
// Server Script Status
@ -3397,6 +3402,5 @@ function loaded() {
setTimeout(function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'propertiesPageReady' }));
EventBridge.emitWebEvent(JSON.stringify({ type: 'tooltipsRequest' }));
}, 1000);
}

View file

@ -340,7 +340,7 @@ void TestRunner::runInterfaceWithTestScript() {
QString testScript =
QString("https://raw.githubusercontent.com/") + _user + "/hifi_tests/" + _branch + "/tests/testRecursive.js";
QString commandLine = exeFile + " --url " + url + " --no-updater --no-login" + " --testScript " + testScript +
QString commandLine = exeFile + " --url " + url + " --no-updater --no-login-suggestion" + " --testScript " + testScript +
" quitWhenFinished --testResultsLocation " + snapshotFolder;
interfaceWorker->setCommandLine(commandLine);