mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
update lobby for new places API
This commit is contained in:
parent
ef87b59a0c
commit
79d214619d
2 changed files with 29 additions and 36 deletions
|
@ -66,20 +66,20 @@ function textOverlayPosition() {
|
||||||
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
|
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
var panelLocationOrder = [
|
var panelPlaceOrder = [
|
||||||
7, 8, 9, 10, 11, 12, 13,
|
7, 8, 9, 10, 11, 12, 13,
|
||||||
0, 1, 2, 3, 4, 5, 6,
|
0, 1, 2, 3, 4, 5, 6,
|
||||||
14, 15, 16, 17, 18, 19, 20
|
14, 15, 16, 17, 18, 19, 20
|
||||||
];
|
];
|
||||||
|
|
||||||
// Location index is 0-based
|
// place index is 0-based
|
||||||
function locationIndexToPanelIndex(locationIndex) {
|
function placeIndexToPanelIndex(placeIndex) {
|
||||||
return panelLocationOrder.indexOf(locationIndex) + 1;
|
return panelPlaceOrder.indexOf(placeIndex) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panel index is 1-based
|
// Panel index is 1-based
|
||||||
function panelIndexToLocationIndex(panelIndex) {
|
function panelIndexToPlaceIndex(panelIndex) {
|
||||||
return panelLocationOrder[panelIndex - 1];
|
return panelPlaceOrder[panelIndex - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
var MAX_NUM_PANELS = 21;
|
var MAX_NUM_PANELS = 21;
|
||||||
|
@ -148,25 +148,25 @@ function drawLobby() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var locations = {};
|
var places = {};
|
||||||
|
|
||||||
function changeLobbyTextures() {
|
function changeLobbyTextures() {
|
||||||
var req = new XMLHttpRequest();
|
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();
|
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 = {
|
var textureProp = {
|
||||||
textures: {}
|
textures: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var j = 0; j < NUM_PANELS; j++) {
|
for (var j = 0; j < NUM_PANELS; j++) {
|
||||||
var panelIndex = locationIndexToPanelIndex(j);
|
var panelIndex = placeIndexToPanelIndex(j);
|
||||||
textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/locations/"
|
textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/places/"
|
||||||
+ locations[j].id + "/hifi-location-" + locations[j].id + "_640x360.jpg";
|
+ place[j].id + "/hifi-place-" + place[j].id + "_640x360.jpg";
|
||||||
};
|
};
|
||||||
|
|
||||||
Overlays.editOverlay(panelWall, textureProp);
|
Overlays.editOverlay(panelWall, textureProp);
|
||||||
|
@ -234,7 +234,7 @@ function cleanupLobby() {
|
||||||
Audio.stopInjector(currentMuzakInjector);
|
Audio.stopInjector(currentMuzakInjector);
|
||||||
currentMuzakInjector = null;
|
currentMuzakInjector = null;
|
||||||
|
|
||||||
locations = {};
|
places = {};
|
||||||
toggleEnvironmentRendering(true);
|
toggleEnvironmentRendering(true);
|
||||||
|
|
||||||
MyAvatar.detachOne(HELMET_ATTACHMENT_URL);
|
MyAvatar.detachOne(HELMET_ATTACHMENT_URL);
|
||||||
|
@ -252,14 +252,14 @@ function actionStartEvent(event) {
|
||||||
var panelStringIndex = panelName.indexOf("Panel");
|
var panelStringIndex = panelName.indexOf("Panel");
|
||||||
if (panelStringIndex != -1) {
|
if (panelStringIndex != -1) {
|
||||||
var panelIndex = parseInt(panelName.slice(5));
|
var panelIndex = parseInt(panelName.slice(5));
|
||||||
var locationIndex = panelIndexToLocationIndex(panelIndex);
|
var placeIndex = panelIndexToPlaceIndex(panelIndex);
|
||||||
if (locationIndex < locations.length) {
|
if (placeIndex < place.length) {
|
||||||
var actionLocation = locations[locationIndex];
|
var actionPlace = places[placeIndex];
|
||||||
|
|
||||||
print("Jumping to " + actionLocation.name + " at " + actionLocation.path
|
print("Jumping to " + actionPlace.name + " at " + actionPlace.address
|
||||||
+ " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex);
|
+ " after click on panel " + panelIndex + " with place index " + placeIndex);
|
||||||
|
|
||||||
Window.location = actionLocation;
|
Window.location = actionPlace.address;
|
||||||
maybeCleanupLobby();
|
maybeCleanupLobby();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,15 +302,15 @@ function handleLookAt(pickRay) {
|
||||||
var panelStringIndex = panelName.indexOf("Panel");
|
var panelStringIndex = panelName.indexOf("Panel");
|
||||||
if (panelStringIndex != -1) {
|
if (panelStringIndex != -1) {
|
||||||
var panelIndex = parseInt(panelName.slice(5));
|
var panelIndex = parseInt(panelName.slice(5));
|
||||||
var locationIndex = panelIndexToLocationIndex(panelIndex);
|
var placeIndex = panelIndexToPlaceIndex(panelIndex);
|
||||||
if (locationIndex < locations.length) {
|
if (placeIndex < places.length) {
|
||||||
var actionLocation = locations[locationIndex];
|
var actionPlace = places[placeIndex];
|
||||||
|
|
||||||
if (actionLocation.description == "") {
|
if (actionPlace.description == "") {
|
||||||
Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText });
|
Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText });
|
||||||
} else {
|
} else {
|
||||||
// handle line wrapping
|
// handle line wrapping
|
||||||
var allWords = actionLocation.description.split(" ");
|
var allWords = actionPlace.description.split(" ");
|
||||||
var currentGoodLine = "";
|
var currentGoodLine = "";
|
||||||
var currentTestLine = "";
|
var currentTestLine = "";
|
||||||
var formatedDescription = "";
|
var formatedDescription = "";
|
||||||
|
|
|
@ -25,16 +25,9 @@ QScriptValue LocationScriptingInterface::locationGetter(QScriptContext* context,
|
||||||
QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) {
|
QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) {
|
||||||
const QVariant& argumentVariant = context->argument(0).toVariant();
|
const QVariant& argumentVariant = context->argument(0).toVariant();
|
||||||
|
|
||||||
|
// just try and convert the argument to a string, should be a hifi:// address
|
||||||
if (argumentVariant.canConvert(QMetaType::QVariantMap)) {
|
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "handleLookupString",
|
||||||
// this argument is a variant map, so we'll assume it's an address map
|
Q_ARG(const QString&, argumentVariant.toString()));
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().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<AddressManager>().data(), "handleLookupString",
|
|
||||||
Q_ARG(const QString&, argumentVariant.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return QScriptValue::UndefinedValue;
|
return QScriptValue::UndefinedValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue