From 79d214619deb343d66a6ee02c530474045f01080 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 14 Jan 2015 18:18:26 -0800 Subject: [PATCH] update lobby for new places API --- examples/lobby.js | 52 +++++++++---------- .../scripting/LocationScriptingInterface.cpp | 13 ++--- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index 15a8aca328..829f399e06 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -66,20 +66,20 @@ function textOverlayPosition() { Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN)); } -var panelLocationOrder = [ +var panelPlaceOrder = [ 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 14, 15, 16, 17, 18, 19, 20 ]; -// Location index is 0-based -function locationIndexToPanelIndex(locationIndex) { - return panelLocationOrder.indexOf(locationIndex) + 1; +// place index is 0-based +function placeIndexToPanelIndex(placeIndex) { + return panelPlaceOrder.indexOf(placeIndex) + 1; } // Panel index is 1-based -function panelIndexToLocationIndex(panelIndex) { - return panelLocationOrder[panelIndex - 1]; +function panelIndexToPlaceIndex(panelIndex) { + return panelPlaceOrder[panelIndex - 1]; } var MAX_NUM_PANELS = 21; @@ -148,25 +148,25 @@ function drawLobby() { } } -var locations = {}; +var places = {}; function changeLobbyTextures() { var req = new XMLHttpRequest(); - req.open("GET", "https://data.highfidelity.io/api/v1/locations?limit=21", false); + req.open("GET", "https://data.highfidelity.io/api/v1/places?limit=21", false); req.send(); - locations = JSON.parse(req.responseText).data.locations; + places = JSON.parse(req.responseText).data.places; - var NUM_PANELS = locations.length; + var NUM_PANELS = places.length; var textureProp = { textures: {} }; for (var j = 0; j < NUM_PANELS; j++) { - var panelIndex = locationIndexToPanelIndex(j); - textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/locations/" - + locations[j].id + "/hifi-location-" + locations[j].id + "_640x360.jpg"; + var panelIndex = placeIndexToPanelIndex(j); + textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/places/" + + place[j].id + "/hifi-place-" + place[j].id + "_640x360.jpg"; }; Overlays.editOverlay(panelWall, textureProp); @@ -234,7 +234,7 @@ function cleanupLobby() { Audio.stopInjector(currentMuzakInjector); currentMuzakInjector = null; - locations = {}; + places = {}; toggleEnvironmentRendering(true); MyAvatar.detachOne(HELMET_ATTACHMENT_URL); @@ -252,14 +252,14 @@ function actionStartEvent(event) { var panelStringIndex = panelName.indexOf("Panel"); if (panelStringIndex != -1) { var panelIndex = parseInt(panelName.slice(5)); - var locationIndex = panelIndexToLocationIndex(panelIndex); - if (locationIndex < locations.length) { - var actionLocation = locations[locationIndex]; + var placeIndex = panelIndexToPlaceIndex(panelIndex); + if (placeIndex < place.length) { + var actionPlace = places[placeIndex]; - print("Jumping to " + actionLocation.name + " at " + actionLocation.path - + " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex); + print("Jumping to " + actionPlace.name + " at " + actionPlace.address + + " after click on panel " + panelIndex + " with place index " + placeIndex); - Window.location = actionLocation; + Window.location = actionPlace.address; maybeCleanupLobby(); } } @@ -302,15 +302,15 @@ function handleLookAt(pickRay) { var panelStringIndex = panelName.indexOf("Panel"); if (panelStringIndex != -1) { var panelIndex = parseInt(panelName.slice(5)); - var locationIndex = panelIndexToLocationIndex(panelIndex); - if (locationIndex < locations.length) { - var actionLocation = locations[locationIndex]; + var placeIndex = panelIndexToPlaceIndex(panelIndex); + if (placeIndex < places.length) { + var actionPlace = places[placeIndex]; - if (actionLocation.description == "") { - Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText }); + if (actionPlace.description == "") { + Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText }); } else { // handle line wrapping - var allWords = actionLocation.description.split(" "); + var allWords = actionPlace.description.split(" "); var currentGoodLine = ""; var currentTestLine = ""; var formatedDescription = ""; diff --git a/interface/src/scripting/LocationScriptingInterface.cpp b/interface/src/scripting/LocationScriptingInterface.cpp index fda9875837..c0a9a62ff3 100644 --- a/interface/src/scripting/LocationScriptingInterface.cpp +++ b/interface/src/scripting/LocationScriptingInterface.cpp @@ -25,16 +25,9 @@ QScriptValue LocationScriptingInterface::locationGetter(QScriptContext* context, QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) { const QVariant& argumentVariant = context->argument(0).toVariant(); - - if (argumentVariant.canConvert(QMetaType::QVariantMap)) { - // this argument is a variant map, so we'll assume it's an address map - QMetaObject::invokeMethod(DependencyManager::get().data(), "goToAddressFromObject", - Q_ARG(const QVariantMap&, argumentVariant.toMap())); - } else { - // just try and convert the argument to a string, should be a hifi:// address - QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", - Q_ARG(const QString&, argumentVariant.toString())); - } + // just try and convert the argument to a string, should be a hifi:// address + QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", + Q_ARG(const QString&, argumentVariant.toString())); return QScriptValue::UndefinedValue; }