added notifications (faked user name for now), along with switch to avatar entities

This commit is contained in:
David Kelly 2017-03-27 11:28:57 -07:00
parent 0edcdde746
commit 76657a670c
4 changed files with 32 additions and 5 deletions

View file

@ -235,6 +235,14 @@ void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& hr
qApp->shareSnapshot(path, href);
}
void WindowScriptingInterface::makeConnection(bool success, const QString& userNameOrError) {
if (success) {
emit connectionAdded(userNameOrError);
} else {
emit connectionError(userNameOrError);
}
}
bool WindowScriptingInterface::isPhysicsEnabled() {
return qApp->isPhysicsEnabled();
}
@ -255,7 +263,7 @@ int WindowScriptingInterface::openMessageBox(QString title, QString text, int bu
}
int WindowScriptingInterface::createMessageBox(QString title, QString text, int buttons, int defaultButton) {
auto messageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
auto messageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton));
connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int)));

View file

@ -56,6 +56,7 @@ public slots:
void showAssetServer(const QString& upload = "");
void copyToClipboard(const QString& text);
void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f);
void makeConnection(bool success, const QString& userNameOrError);
void shareSnapshot(const QString& path, const QUrl& href = QUrl(""));
bool isPhysicsEnabled();
@ -74,6 +75,9 @@ signals:
void snapshotShared(const QString& error);
void processingGif();
void connectionAdded(const QString& connectionName);
void connectionError(const QString& errorString);
void messageBoxClosed(int id, int button);
// triggered when window size or position changes

View file

@ -271,7 +271,8 @@ function updateVisualization() {
particleProps = PARTICLE_EFFECT_PROPS;
particleProps.isEmitting = 0;
particleProps.position = calcParticlePos(myHandPosition, otherHand, otherOrientation);
particleEffect = Entities.addEntity(particleProps);
particleProps.parentID = MyAvatar.sessionUUID;
particleEffect = Entities.addEntity(particleProps, true);
} else {
particleProps.position = calcParticlePos(myHandPosition, otherHand, otherOrientation);
particleProps.isEmitting = 1;
@ -279,10 +280,11 @@ function updateVisualization() {
}
if (!makingConnectionParticleEffect) {
var props = MAKING_CONNECTION_PARTICLE_PROPS;
props.parentID = MyAvatar.sessionUUID;
makingConnectionEmitRate = 2000;
props.emitRate = makingConnectionEmitRate;
props.position = myHandPosition;
makingConnectionParticleEffect = Entities.addEntity(props);
makingConnectionParticleEffect = Entities.addEntity(props, true);
} else {
makingConnectionEmitRate *= 0.5;
Entities.editEntity(makingConnectionParticleEffect, {emitRate: makingConnectionEmitRate, position: myHandPosition, isEmitting: 1});
@ -485,7 +487,6 @@ function makeConnection(id) {
// probably, in which we do this.
Controller.triggerHapticPulse(HAPTIC_DATA.background.strength, MAKING_CONNECTION_TIMEOUT, handToHaptic(currentHand));
// now that we made connection, reset everything
makingFriendsTimeout = Script.setTimeout(function () {
if (!successfulHandshakeInjector) {
successfulHandshakeInjector = Audio.playSound(successfulHandshakeSound, {position: getHandPosition(MyAvatar, currentHand), volume: 0.5, localOnly: true});
@ -494,6 +495,8 @@ function makeConnection(id) {
}
Controller.triggerHapticPulse(HAPTIC_DATA.success.strength, HAPTIC_DATA.success.duration, handToHaptic(currentHand));
// don't change state (so animation continues while gripped)
// but do send a notification, by calling the slot that emits the signal for it
Window.makeConnection(true, "otherGuy"); // this is successful, unsucessful would be false, errorString
}, MAKING_CONNECTION_TIMEOUT);
}

View file

@ -94,11 +94,13 @@ var NotificationType = {
LOD_WARNING: 2,
CONNECTION_REFUSED: 3,
EDIT_ERROR: 4,
CONNECTION: 5,
properties: [
{ text: "Snapshot" },
{ text: "Level of Detail" },
{ text: "Connection Refused" },
{ text: "Edit error" }
{ text: "Edit error" },
{ text: "Connection" }
],
getTypeFromMenuItem: function(menuItemName) {
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
@ -539,6 +541,14 @@ function processingGif() {
createNotification("Processing GIF snapshot...", NotificationType.SNAPSHOT);
}
function connectionAdded(connectionName) {
createNotification(wordWrap("Successfully connected to " + connectionName), NotificationType.CONNECTION);
}
function connectionError(error) {
createNotification(wordWrap("Error trying to make connection: " + error), NotificationType.CONNECTION);
}
// handles mouse clicks on buttons
function mousePressEvent(event) {
var pickRay,
@ -639,6 +649,8 @@ Menu.menuItemEvent.connect(menuItemEvent);
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
Window.snapshotTaken.connect(onSnapshotTaken);
Window.processingGif.connect(processingGif);
Window.connectionAdded.connect(connectionAdded);
Window.connectionError.connect(connectionError);
Window.notifyEditError = onEditError;
Window.notify = onNotify;