From c39bd362b734ad3b0f3f3fa438dd6792d05eec23 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 18 Nov 2014 09:52:00 -0800 Subject: [PATCH 01/13] Fix grid controls not updateable --- examples/html/gridControls.html | 49 +++++++++++++++++---------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/examples/html/gridControls.html b/examples/html/gridControls.html index 4cb935e600..93bbf7b445 100644 --- a/examples/html/gridControls.html +++ b/examples/html/gridControls.html @@ -12,14 +12,13 @@ { red: 0, green: 0, blue: 255 }, ]; - posY = document.getElementById("horiz-y"); - minorSpacing = document.getElementById("minor-spacing"); - majorSpacing = document.getElementById("major-spacing"); - gridOn = document.getElementById("grid-on"); - snapToGrid = document.getElementById("snap-to-grid"); - hGridVisible = document.getElementById("horiz-grid-visible"); - bMoveToSelection = document.getElementById("move-to-selection"); - bMoveToAvatar = document.getElementById("move-to-avatar"); + elPosY = document.getElementById("horiz-y"); + elMinorSpacing = document.getElementById("minor-spacing"); + elMajorSpacing = document.getElementById("major-spacing"); + elSnapToGrid = document.getElementById("snap-to-grid"); + elHorizontalGridVisible = document.getElementById("horiz-grid-visible"); + elMoveToSelection = document.getElementById("move-to-selection"); + elMoveToAvatar = document.getElementById("move-to-avatar"); if (window.EventBridge !== undefined) { EventBridge.scriptEventReceived.connect(function(data) { @@ -27,27 +26,27 @@ if (data.origin) { var origin = data.origin; - posY.value = origin.y; + elPosY.value = origin.y.toFixed(2); } if (data.minorGridSpacing) { - minorSpacing.value = data.minorGridSpacing; + elMinorSpacing.value = data.minorGridSpacing; } if (data.majorGridEvery) { - majorSpacing.value = data.majorGridEvery; + elMajorSpacing.value = data.majorGridEvery; } if (data.gridColor) { gridColor = data.gridColor; } - if (data.snapToGrid !== undefined) { - snapToGrid.checked = data.snapToGrid == true; + if (data.elSnapToGrid !== undefined) { + elSnapToGrid.checked = data.elSnapToGrid == true; } if (data.visible !== undefined) { - hGridVisible.checked = data.visible == true; + elHorizontalGridVisible.checked = data.visible == true; } }); @@ -55,29 +54,31 @@ EventBridge.emitWebEvent(JSON.stringify({ type: "update", origin: { - y: posY.value, + y: elPosY.value, }, - minorGridSpacing: minorSpacing.value, - majorGridEvery: majorSpacing.value, + minorGridSpacing: elMinorSpacing.value, + majorGridEvery: elMajorSpacing.value, gridColor: gridColor, - snapToGrid: snapToGrid.checked, - visible: hGridVisible.checked, + elSnapToGrid: elSnapToGrid.checked, + visible: elHorizontalGridVisible.checked, })); } } - document.addEventListener("input", emitUpdate); - hGridVisible.addEventListener("change", emitUpdate); - snapToGrid.addEventListener("change", emitUpdate); + elPosY.addEventListener("change", emitUpdate); + elMinorSpacing.addEventListener("change", emitUpdate); + elMajorSpacing.addEventListener("change", emitUpdate); + elSnapToGrid.addEventListener("change", emitUpdate); + elHorizontalGridVisible.addEventListener("change", emitUpdate); - bMoveToAvatar.addEventListener("click", function() { + elMoveToAvatar.addEventListener("click", function() { EventBridge.emitWebEvent(JSON.stringify({ type: "action", action: "moveToAvatar", })); }); - bMoveToSelection.addEventListener("click", function() { + elMoveToSelection.addEventListener("click", function() { EventBridge.emitWebEvent(JSON.stringify({ type: "action", action: "moveToSelection", From 10008cb41f0e23dcaa88b328d693bb679dbb16ca Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 18 Nov 2014 10:27:26 -0800 Subject: [PATCH 02/13] Fix snapToGrid checkbox not working --- examples/html/gridControls.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/html/gridControls.html b/examples/html/gridControls.html index 93bbf7b445..241fa2406c 100644 --- a/examples/html/gridControls.html +++ b/examples/html/gridControls.html @@ -42,7 +42,7 @@ } if (data.elSnapToGrid !== undefined) { - elSnapToGrid.checked = data.elSnapToGrid == true; + elSnapToGrid.checked = data.snapToGrid == true; } if (data.visible !== undefined) { @@ -59,7 +59,7 @@ minorGridSpacing: elMinorSpacing.value, majorGridEvery: elMajorSpacing.value, gridColor: gridColor, - elSnapToGrid: elSnapToGrid.checked, + snapToGrid: elSnapToGrid.checked, visible: elHorizontalGridVisible.checked, })); } From a4cc12e448f5fec600748cb1e0b2d0c4d569b944 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 18 Nov 2014 10:28:03 -0800 Subject: [PATCH 03/13] Add snapToSpacing functionality --- examples/libraries/entitySelectionTool.js | 2 ++ examples/libraries/gridTool.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 6733ccaf39..ada876e9b1 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -1403,6 +1403,8 @@ SelectionDisplay = (function () { vector = vec3Mult(mask, vector); + vector = grid.snapToSpacing(vector); + var changeInDimensions = Vec3.multiply(-1, vec3Mult(signs, vector)); var newDimensions; if (proportional) { diff --git a/examples/libraries/gridTool.js b/examples/libraries/gridTool.js index d8b84babf9..36d40648b4 100644 --- a/examples/libraries/gridTool.js +++ b/examples/libraries/gridTool.js @@ -69,6 +69,24 @@ Grid = function(opts) { return Vec3.sum(position, origin); } + that.snapToSpacing = function(delta, majorOnly) { + print('snaptogrid? ' + snapToGrid); + if (!snapToGrid) { + return delta; + } + + var spacing = majorOnly ? (minorGridSpacing * majorGridEvery) : minorGridSpacing; + + var snappedDelta = { + x: Math.round(delta.x / spacing) * spacing, + y: Math.round(delta.y / spacing) * spacing, + z: Math.round(delta.z / spacing) * spacing, + }; + + return snappedDelta; + } + + that.setPosition = function(newPosition, noUpdate) { origin = Vec3.subtract(newPosition, { x: 0, y: yOffset, z: 0 }); origin.x = 0; From 16e3887cbc32509851e3b25deffffbba3e84be93 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 18 Nov 2014 10:28:14 -0800 Subject: [PATCH 04/13] Set snapToGrid to default to false --- examples/libraries/gridTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/libraries/gridTool.js b/examples/libraries/gridTool.js index 36d40648b4..eb2a227248 100644 --- a/examples/libraries/gridTool.js +++ b/examples/libraries/gridTool.js @@ -15,7 +15,7 @@ Grid = function(opts) { var minorGridWidth = 0.5; var majorGridWidth = 1.5; - var snapToGrid = true; + var snapToGrid = false; var gridOverlay = Overlays.addOverlay("grid", { position: { x: 0 , y: 0, z: 0 }, From ad3d7fbfb4dca6d1cf6e367a362ed92882f4981f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 18 Nov 2014 12:24:52 -0800 Subject: [PATCH 05/13] Improve performance of drawing GridOverlay3D --- interface/src/ui/overlays/Grid3DOverlay.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/interface/src/ui/overlays/Grid3DOverlay.cpp b/interface/src/ui/overlays/Grid3DOverlay.cpp index 84610d7981..4bf0d9ce93 100644 --- a/interface/src/ui/overlays/Grid3DOverlay.cpp +++ b/interface/src/ui/overlays/Grid3DOverlay.cpp @@ -69,9 +69,10 @@ void Grid3DOverlay::render(RenderArgs* args) { xColor color = getColor(); glm::vec3 position = getPosition(); - const int GRID_DIVISIONS = 300; + const int MINOR_GRID_DIVISIONS = 100; + const int MAJOR_GRID_DIVISIONS = 50; const float MAX_COLOR = 255.0f; - float scale = GRID_DIVISIONS * spacing; + glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); @@ -80,12 +81,13 @@ void Grid3DOverlay::render(RenderArgs* args) { // Minor grid glPushMatrix(); { - glTranslatef(_minorGridWidth * (floorf(rotated.x / spacing) - GRID_DIVISIONS / 2), - spacing * (floorf(rotated.y / spacing) - GRID_DIVISIONS / 2), position.z); + glTranslatef(_minorGridWidth * (floorf(rotated.x / spacing) - MINOR_GRID_DIVISIONS / 2), + spacing * (floorf(rotated.y / spacing) - MINOR_GRID_DIVISIONS / 2), position.z); + float scale = MINOR_GRID_DIVISIONS * spacing; glScalef(scale, scale, scale); - Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS); + Application::getInstance()->getGeometryCache()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS); } glPopMatrix(); @@ -94,13 +96,13 @@ void Grid3DOverlay::render(RenderArgs* args) { { glLineWidth(4.0f); spacing *= _majorGridEvery; - glTranslatef(spacing * (floorf(rotated.x / spacing) - GRID_DIVISIONS / 2), - spacing * (floorf(rotated.y / spacing) - GRID_DIVISIONS / 2), position.z); + glTranslatef(spacing * (floorf(rotated.x / spacing) - MAJOR_GRID_DIVISIONS / 2), + spacing * (floorf(rotated.y / spacing) - MAJOR_GRID_DIVISIONS / 2), position.z); - scale *= _majorGridEvery; + float scale = MAJOR_GRID_DIVISIONS * spacing; glScalef(scale, scale, scale); - Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS); + Application::getInstance()->getGeometryCache()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS); } glPopMatrix(); From 2bfd3d213a6a14fcfc2bde34ab74f40af853d018 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 18 Nov 2014 12:50:37 -0800 Subject: [PATCH 06/13] Update ToolWindow to auto-hide itself when main window loses focus --- interface/src/ui/ToolWindow.cpp | 38 +++++++++++++++++++++++++++++++-- interface/src/ui/ToolWindow.h | 4 ++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/ToolWindow.cpp b/interface/src/ui/ToolWindow.cpp index 1375ff1ea5..44ea44c47d 100644 --- a/interface/src/ui/ToolWindow.cpp +++ b/interface/src/ui/ToolWindow.cpp @@ -19,6 +19,8 @@ ToolWindow::ToolWindow(QWidget* parent) : QMainWindow(parent), _hasShown(false), _lastGeometry() { + + Application::getInstance()->installEventFilter(this); } bool ToolWindow::event(QEvent* event) { @@ -47,8 +49,37 @@ bool ToolWindow::event(QEvent* event) { return QMainWindow::event(event); } +bool ToolWindow::eventFilter(QObject* sender, QEvent* event) { + switch (event->type()) { + case QEvent::WindowStateChange: + if (Application::getInstance()->getWindow()->isMinimized()) { + // If we are already visible, we are self-hiding + _selfHidden = isVisible(); + setVisible(false); + } else { + if (_selfHidden) { + setVisible(true); + } + } + break; + case QEvent::ApplicationDeactivate: + _selfHidden = isVisible(); + setVisible(false); + break; + case QEvent::ApplicationActivate: + if (_selfHidden) { + setVisible(true); + } + break; + default: + break; + } + + return false; +} + void ToolWindow::onChildVisibilityUpdated(bool visible) { - if (visible) { + if (!_selfHidden && visible) { setVisible(true); } else { bool hasVisible = false; @@ -59,7 +90,10 @@ void ToolWindow::onChildVisibilityUpdated(bool visible) { break; } } - setVisible(hasVisible); + // If a child was hidden and we don't have any children still visible, hide ourself. + if (!hasVisible) { + setVisible(false); + } } } diff --git a/interface/src/ui/ToolWindow.h b/interface/src/ui/ToolWindow.h index 87b94d46df..03ae85a418 100644 --- a/interface/src/ui/ToolWindow.h +++ b/interface/src/ui/ToolWindow.h @@ -28,11 +28,15 @@ public: virtual void addDockWidget(Qt::DockWidgetArea area, QDockWidget* dockWidget, Qt::Orientation orientation); virtual void removeDockWidget(QDockWidget* dockWidget); + virtual bool eventFilter(QObject* sender, QEvent* event); + public slots: void onChildVisibilityUpdated(bool visible); private: + // Indicates whether this window was hidden by itself (because the main window lost focus). + bool _selfHidden; bool _hasShown; QRect _lastGeometry; }; From b53124cba7ef1ad2f68c39e0a8258f2352c8b25a Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 18 Nov 2014 14:25:12 -0800 Subject: [PATCH 07/13] tweaks to sound behavior --- examples/entityScripts/movable.js | 149 ++++++++++++++++++++++++------ 1 file changed, 120 insertions(+), 29 deletions(-) diff --git a/examples/entityScripts/movable.js b/examples/entityScripts/movable.js index 94ed7137fe..91042411af 100644 --- a/examples/entityScripts/movable.js +++ b/examples/entityScripts/movable.js @@ -15,17 +15,37 @@ this.graboffset = null; this.clickedAt = null; this.firstHolding = true; - this.clickedX = -1; - this.clickedY = -1; + this.clicked = { x: -1, y: -1}; + this.lastMovedPosition = { x: -1, y: -1}; + this.lastMovedTime = 0; this.rotateOverlayTarget = null; this.rotateOverlayInner = null; this.rotateOverlayOuter = null; this.rotateOverlayCurrent = null; this.rotateMode = false; this.originalRotation = null; - this.sound = null; + + this.moveSoundURLS = [ + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove1.wav", + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove2.wav", + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove3.wav" + ]; + + this.turnSoundURLS = [ + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn1.wav", + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn2.wav", + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn3.wav" + ]; + + + this.moveSounds = new Array(); + this.turnSounds = new Array(); + this.moveSound = null; + this.turnSound = null; this.injector = null; + var debug = false; + var displayRotateTargets = true; // change to false if you don't want the rotate targets var rotateOverlayTargetSize = 10000; // really big target var innerSnapAngle = 22.5; // the angle which we snap to on the inner rotation tool var innerRadius; @@ -34,25 +54,62 @@ var yawZero; var rotationNormal; var yawNormal; + var stopSoundDelay = 100; // number of msecs of not moving to have sound stop - var debug = true; + this.getRandomInt = function(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } - // Download sound if needed - this.maybeDownloadSound = function() { - if (this.sound === null) { - this.sound = SoundCache.getSound("http://public.highfidelity.io/sounds/Collisions-otherorganic/whoosh2.raw"); + this.downloadSounds = function() { + for (var i = 0; i < this.moveSoundURLS.length; i++) { + this.moveSounds[i] = SoundCache.getSound(this.moveSoundURLS[i]); } - } - // Play drag sound - this.playSound = function() { - this.stopSound(); - if (this.sound && this.sound.downloaded) { - this.injector = Audio.playSound(this.sound, { position: this.properties.position, loop: true, volume: 0.1 }); + for (var i = 0; i < this.turnSoundURLS.length; i++) { + this.turnSounds[i] = SoundCache.getSound(this.turnSoundURLS[i]); } } - // stop drag sound + this.pickRandomSounds = function() { + var moveIndex = this.getRandomInt(0, this.moveSounds.length - 1); + var turnIndex = this.getRandomInt(0, this.turnSounds.length - 1); + if (debug) { + print("Random sounds -- turn:" + turnIndex + " move:" + moveIndex); + } + this.moveSound = this.moveSounds[moveIndex]; + this.turnSound = this.turnSounds[turnIndex]; + } + + // Play move sound + this.playMoveSound = function() { + if (debug) { + print("playMoveSound()"); + } + if (this.moveSound && this.moveSound.downloaded) { + if (debug) { + print("playMoveSound() --- calling this.injector = Audio.playSound(this.moveSound...)"); + } + this.injector = Audio.playSound(this.moveSound, { position: this.properties.position, loop: true, volume: 0.1 }); + } + } + + // Play turn sound + this.playTurnSound = function() { + if (debug) { + print("playTurnSound()"); + } + if (this.turnSound && this.turnSound.downloaded) { + if (debug) { + print("playTurnSound() --- calling this.injector = Audio.playSound(this.turnSound...)"); + } + this.injector = Audio.playSound(this.turnSound, { position: this.properties.position, loop: true, volume: 0.1 }); + } + } + + // stop sound this.stopSound = function() { + if (debug) { + print("stopSound()"); + } if (this.injector) { Audio.stopInjector(this.injector); this.injector = null; @@ -86,11 +143,33 @@ this.properties.position, upVector); this.graboffset = Vec3.subtract(this.properties.position, intersection); }; - + + this.stopSoundIfNotMoving = function(mouseEvent) { + var nowDate = new Date(); + var nowMSecs = nowDate.getTime(); + if(mouseEvent.x == this.lastMovedPosition.x && mouseEvent.y == this.lastMovedPosition.y) { + var elapsedSinceLastMove = nowMSecs - this.lastMovedMSecs; + if (debug) { + print("elapsedSinceLastMove:" + elapsedSinceLastMove); + } + if (elapsedSinceLastMove > stopSoundDelay) { + if (debug) { + print("calling stopSound()..."); + } + this.stopSound(); + } + } else { + // if we've moved, then track our last move position and time... + this.lastMovedMSecs = nowMSecs; + this.lastMovedPosition.x = mouseEvent.x; + this.lastMovedPosition.y = mouseEvent.y; + } + } + this.move = function(mouseEvent) { this.updatePosition(mouseEvent); if (this.injector === null) { - this.playSound(); + this.playMoveSound(); } }; @@ -146,7 +225,11 @@ majorTickMarksAngle: 45.0, minorTickMarksAngle: 5, majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, }); } - } + } + + if (this.injector === null) { + this.playTurnSound(); + } }; // All callbacks start by updating the properties this.updateProperties = function(entityID) { @@ -185,7 +268,7 @@ this.rotateOverlayTarget = Overlays.addOverlay("circle3d", { position: this.properties.position, - size: 10000, + size: rotateOverlayTargetSize, color: { red: 0, green: 0, blue: 0 }, alpha: 0.0, solid: true, @@ -201,7 +284,7 @@ alpha: innerAlpha, color: { red: 51, green: 152, blue: 203 }, solid: true, - visible: true, + visible: displayRotateTargets, rotation: yawOverlayRotation, hasTickMarks: true, majorTickMarksAngle: innerSnapAngle, @@ -222,7 +305,7 @@ alpha: outerAlpha, color: { red: 51, green: 152, blue: 203 }, solid: true, - visible: true, + visible: displayRotateTargets, rotation: yawOverlayRotation, hasTickMarks: true, @@ -244,7 +327,7 @@ color: { red: 224, green: 67, blue: 36}, alpha: 0.8, solid: true, - visible: true, + visible: displayRotateTargets, rotation: yawOverlayRotation, ignoreRayIntersection: true, // always ignore this hasTickMarks: true, @@ -260,19 +343,25 @@ this.preload = function(entityID) { this.updateProperties(entityID); // All callbacks start by updating the properties - this.maybeDownloadSound(); + this.downloadSounds(); }; this.clickDownOnEntity = function(entityID, mouseEvent) { this.updateProperties(entityID); // All callbacks start by updating the properties this.grab(mouseEvent); - var d = new Date(); - this.clickedAt = d.getTime(); + var nowDate = new Date(); + var nowMSecs = nowDate.getTime(); + this.clickedAt = nowMSecs; this.firstHolding = true; - this.clickedX = mouseEvent.x; - this.clickedY = mouseEvent.y; + this.clicked.x = mouseEvent.x; + this.clicked.y = mouseEvent.y; + this.lastMovedPosition.x = mouseEvent.x; + this.lastMovedPosition.y = mouseEvent.y; + this.lastMovedMSecs = nowMSecs; + + this.pickRandomSounds(); }; this.holdingClickOnEntity = function(entityID, mouseEvent) { @@ -281,7 +370,7 @@ if (this.firstHolding) { // if we haven't moved yet... - if (this.clickedX == mouseEvent.x && this.clickedY == mouseEvent.y) { + if (this.clicked.x == mouseEvent.x && this.clicked.y == mouseEvent.y) { var d = new Date(); var now = d.getTime(); @@ -295,12 +384,14 @@ this.firstHolding = false; } } - + if (this.rotateMode) { this.rotate(mouseEvent); } else { this.move(mouseEvent); } + + this.stopSoundIfNotMoving(mouseEvent); }; this.clickReleaseOnEntity = function(entityID, mouseEvent) { this.updateProperties(entityID); // All callbacks start by updating the properties From c07083568106a0bcf4c9d55c9651b114317f682c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 18 Nov 2014 14:41:56 -0800 Subject: [PATCH 08/13] use move sounds for turning until further research and foley work --- examples/entityScripts/movable.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/entityScripts/movable.js b/examples/entityScripts/movable.js index 91042411af..21e6261179 100644 --- a/examples/entityScripts/movable.js +++ b/examples/entityScripts/movable.js @@ -32,9 +32,15 @@ ]; this.turnSoundURLS = [ - "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn1.wav", - "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn2.wav", - "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn3.wav" + + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove1.wav", + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove2.wav", + "http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove3.wav" + + // TODO: determine if these or other turn sounds work better than move sounds. + //"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn1.wav", + //"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn2.wav", + //"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn3.wav" ]; From 2274b35d08ad3614c5d7bb2a4d8b0475ce549916 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Nov 2014 15:35:11 -0800 Subject: [PATCH 09/13] connect to sandbox domain by default --- interface/src/Application.cpp | 7 +++++-- libraries/networking/src/AddressManager.h | 3 ++- libraries/networking/src/DomainHandler.h | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 31be016380..7cc7267f03 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1926,11 +1926,14 @@ void Application::init() { // check if we have a URL in settings to load to jump back to // we load this separate from the other settings so we don't double lookup a URL QSettings* interfaceSettings = lockSettings(); - QUrl addressURL = interfaceSettings->value(SETTINGS_ADDRESS_KEY).toUrl(); + QVariant addressVariant = interfaceSettings->value(SETTINGS_ADDRESS_KEY); - AddressManager::getInstance().handleLookupString(addressURL.toString()); + QString addressString = addressVariant.isNull() + ? DEFAULT_HIFI_ADDRESS : addressVariant.toUrl().toString(); unlockSettings(); + + AddressManager::getInstance().handleLookupString(addressString); } qDebug() << "Loaded settings"; diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index d6ecdc9fc6..cfdaaa7d41 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -19,7 +19,8 @@ #include "AccountManager.h" -static const QString HIFI_URL_SCHEME = "hifi"; +const QString HIFI_URL_SCHEME = "hifi"; +const QString DEFAULT_HIFI_ADDRESS = "hifi://sandbox"; typedef const glm::vec3& (*PositionGetter)(); typedef glm::quat (*OrientationGetter)(); diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index 86c6e6bc57..a27a5d1dd8 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -22,8 +22,6 @@ #include "HifiSockAddr.h" #include "NetworkPeer.h" -const QString DEFAULT_DOMAIN_HOSTNAME = "sandbox.highfidelity.io"; - const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102; const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103; const quint16 DOMAIN_SERVER_HTTP_PORT = 40100; From 1443cece5bf22d5155021ed2c15fc4a8992ed3d7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 18 Nov 2014 16:55:53 -0800 Subject: [PATCH 10/13] Fix singleton object created on temporary thread --- assignment-client/src/AssignmentClient.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 929d6c76c8..ae235eb1ff 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -21,7 +21,7 @@ #include #include #include - +#include #include "AssignmentFactory.h" #include "AssignmentThread.h" @@ -122,7 +122,9 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) : connect(&AccountManager::getInstance(), &AccountManager::authRequired, this, &AssignmentClient::handleAuthenticationRequest); + // Create Singleton objects on main thread NetworkAccessManager::getInstance(); + SoundCache::getInstance(); } void AssignmentClient::sendAssignmentRequest() { From 705d3da0894fb0fd6655cbda25debc2c30402e45 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Nov 2014 17:00:33 -0800 Subject: [PATCH 11/13] cleanup time in log prefix --- libraries/shared/src/LogHandler.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libraries/shared/src/LogHandler.cpp b/libraries/shared/src/LogHandler.cpp index a13f3a9dad..a8c28eb6bf 100644 --- a/libraries/shared/src/LogHandler.cpp +++ b/libraries/shared/src/LogHandler.cpp @@ -10,8 +10,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #ifdef _WIN32 #include #define getpid _getpid @@ -21,6 +19,7 @@ #include // for getpid() on linux #endif +#include #include #include @@ -38,6 +37,10 @@ LogHandler::LogHandler() : QTimer* logFlushTimer = new QTimer(this); connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages); logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000); + + // when the log handler is first setup we should print our timezone + QString timezoneString = "Time zone: " + QDateTime::currentDateTime().toString("t"); + printf("%s\n", qPrintable(timezoneString)); } const char* stringForLogType(LogMsgType msgType) { @@ -57,8 +60,8 @@ const char* stringForLogType(LogMsgType msgType) { } } -// the following will produce 2000-10-02 13:55:36 -0700 -const char DATE_STRING_FORMAT[] = "%Y-%m-%d %H:%M:%S %z"; +// the following will produce 11/18 13:55:36 +const QString DATE_STRING_FORMAT = "MM/dd hh:mm:ss"; void LogHandler::flushRepeatedMessages() { QHash::iterator message = _repeatMessageCountHash.begin(); @@ -112,14 +115,7 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont QString prefixString = QString("[%1]").arg(stringForLogType(type)); - time_t rawTime; - time(&rawTime); - struct tm* localTime = localtime(&rawTime); - - char dateString[100]; - strftime(dateString, sizeof(dateString), DATE_STRING_FORMAT, localTime); - - prefixString.append(QString(" [%1]").arg(dateString)); + prefixString.append(QString(" [%1]").arg(QDateTime::currentDateTime().toString(DATE_STRING_FORMAT))); if (_shouldOutputPID) { prefixString.append(QString(" [%1").arg(getpid())); From 8c65c6c1c840947d2f7b49314273642d27400ba9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Nov 2014 17:02:28 -0800 Subject: [PATCH 12/13] fix comment for actual time format --- libraries/shared/src/LogHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/LogHandler.cpp b/libraries/shared/src/LogHandler.cpp index a8c28eb6bf..4ed6666161 100644 --- a/libraries/shared/src/LogHandler.cpp +++ b/libraries/shared/src/LogHandler.cpp @@ -111,7 +111,7 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont } // log prefix is in the following format - // [DEBUG] [TIMESTAMP] [PID:PARENT_PID] [TARGET] logged string + // [DEBUG] [TIMESTAMP] [PID] [TARGET] logged string QString prefixString = QString("[%1]").arg(stringForLogType(type)); From 44190b6fde5b02d2023cda4d18f718b9ee9c5a10 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 18 Nov 2014 17:25:41 -0800 Subject: [PATCH 13/13] AC ambiance script / moved AC scripts to new directory --- examples/{ => acScripts}/ControlledAC.js | 0 examples/{ => acScripts}/PlayRecordingOnAC.js | 0 examples/acScripts/ambiance.js | 42 +++++++++++++++++++ 3 files changed, 42 insertions(+) rename examples/{ => acScripts}/ControlledAC.js (100%) rename examples/{ => acScripts}/PlayRecordingOnAC.js (100%) create mode 100644 examples/acScripts/ambiance.js diff --git a/examples/ControlledAC.js b/examples/acScripts/ControlledAC.js similarity index 100% rename from examples/ControlledAC.js rename to examples/acScripts/ControlledAC.js diff --git a/examples/PlayRecordingOnAC.js b/examples/acScripts/PlayRecordingOnAC.js similarity index 100% rename from examples/PlayRecordingOnAC.js rename to examples/acScripts/PlayRecordingOnAC.js diff --git a/examples/acScripts/ambiance.js b/examples/acScripts/ambiance.js new file mode 100644 index 0000000000..0149d5d3ff --- /dev/null +++ b/examples/acScripts/ambiance.js @@ -0,0 +1,42 @@ +// +// ambiance.js +// examples +// +// Created by Clément Brisset on 11/18/14. +// Copyright 2014 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 +// + +var soundURL = "https://s3.amazonaws.com/hifi-public/sounds/08_Funny_Bone.wav"; +var position = { x: 700, y: 25, z: 725 }; +var audioOptions = { + position: position, + volume: 0.4, + loop: true, + stereo: false +}; + +var sound = SoundCache.getSound(soundURL, audioOptions.isStereo); +var injector = null; +var count = 100; + +Script.update.connect(function() { + if (count > 0) { + count--; + return; + } + + if (sound.downloaded && injector === null) { + print("Sound downloaded."); + injector = Audio.playSound(sound, audioOptions); + print("Playing: " + injector); + } +}); + +Script.scriptEnding.connect(function() { + if (injector !== null) { + injector.stop(); + } +}); \ No newline at end of file