mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:30:42 +02:00
Merge pull request #8631 from sethalves/avoid-modal-edit-dialogs
edit.js indicates errors via notifications.js
This commit is contained in:
commit
2be961ef10
2 changed files with 61 additions and 42 deletions
|
@ -184,7 +184,7 @@ var toolBar = (function () {
|
||||||
properties.position = position;
|
properties.position = position;
|
||||||
entityID = Entities.addEntity(properties);
|
entityID = Entities.addEntity(properties);
|
||||||
} else {
|
} else {
|
||||||
Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
Window.notifyEditError("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionManager.clearSelections();
|
selectionManager.clearSelections();
|
||||||
|
@ -445,7 +445,7 @@ var toolBar = (function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
||||||
Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG);
|
Window.notifyEditError(INSUFFICIENT_PERMISSIONS_ERROR_MSG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Messages.sendLocalMessage("edit-events", JSON.stringify({
|
Messages.sendLocalMessage("edit-events", JSON.stringify({
|
||||||
|
@ -1082,13 +1082,13 @@ function handeMenuEvent(menuItem) {
|
||||||
deleteSelectedEntities();
|
deleteSelectedEntities();
|
||||||
} else if (menuItem === "Export Entities") {
|
} else if (menuItem === "Export Entities") {
|
||||||
if (!selectionManager.hasSelection()) {
|
if (!selectionManager.hasSelection()) {
|
||||||
Window.alert("No entities have been selected.");
|
Window.notifyEditError("No entities have been selected.");
|
||||||
} else {
|
} else {
|
||||||
var filename = Window.save("Select Where to Save", "", "*.json");
|
var filename = Window.save("Select Where to Save", "", "*.json");
|
||||||
if (filename) {
|
if (filename) {
|
||||||
var success = Clipboard.exportEntities(filename, selectionManager.selections);
|
var success = Clipboard.exportEntities(filename, selectionManager.selections);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
Window.alert("Export failed.");
|
Window.notifyEditError("Export failed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1156,7 @@ function getPositionToImportEntity() {
|
||||||
}
|
}
|
||||||
function importSVO(importURL) {
|
function importSVO(importURL) {
|
||||||
if (!Entities.canAdjustLocks()) {
|
if (!Entities.canAdjustLocks()) {
|
||||||
Window.alert(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG);
|
Window.notifyEditError(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,10 +1188,10 @@ function importSVO(importURL) {
|
||||||
|
|
||||||
Window.raiseMainWindow();
|
Window.raiseMainWindow();
|
||||||
} else {
|
} else {
|
||||||
Window.alert("Can't import objects: objects would be out of bounds.");
|
Window.notifyEditError("Can't import objects: objects would be out of bounds.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Window.alert("There was an error importing the entity file.");
|
Window.notifyEditError("There was an error importing the entity file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlays.editOverlay(importingSVOTextOverlay, {
|
Overlays.editOverlay(importingSVOTextOverlay, {
|
||||||
|
@ -1481,7 +1481,7 @@ var PropertiesTool = function (opts) {
|
||||||
// If any of the natural dimensions are not 0, resize
|
// If any of the natural dimensions are not 0, resize
|
||||||
if (properties.type === "Model" && naturalDimensions.x === 0 && naturalDimensions.y === 0 &&
|
if (properties.type === "Model" && naturalDimensions.x === 0 && naturalDimensions.y === 0 &&
|
||||||
naturalDimensions.z === 0) {
|
naturalDimensions.z === 0) {
|
||||||
Window.alert("Cannot reset entity to its natural dimensions: Model URL" +
|
Window.notifyEditError("Cannot reset entity to its natural dimensions: Model URL" +
|
||||||
" is invalid or the model has not yet been loaded.");
|
" is invalid or the model has not yet been loaded.");
|
||||||
} else {
|
} else {
|
||||||
Entities.editEntity(selectionManager.selections[i], {
|
Entities.editEntity(selectionManager.selections[i], {
|
||||||
|
|
|
@ -58,6 +58,8 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/* global Script, Controller, Overlays, SoundArray, Quat, Vec3, MyAvatar, Menu, HMD, AudioDevice, LODManager, Settings, Camera */
|
||||||
|
|
||||||
(function() { // BEGIN LOCAL_SCOPE
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
Script.include("./libraries/soundArray.js");
|
Script.include("./libraries/soundArray.js");
|
||||||
|
@ -76,11 +78,9 @@ var fontSize = 12.0;
|
||||||
var PERSIST_TIME_2D = 10.0; // Time in seconds before notification fades
|
var PERSIST_TIME_2D = 10.0; // Time in seconds before notification fades
|
||||||
var PERSIST_TIME_3D = 15.0;
|
var PERSIST_TIME_3D = 15.0;
|
||||||
var persistTime = PERSIST_TIME_2D;
|
var persistTime = PERSIST_TIME_2D;
|
||||||
var clickedText = false;
|
|
||||||
var frame = 0;
|
var frame = 0;
|
||||||
var ourWidth = Window.innerWidth;
|
var ourWidth = Window.innerWidth;
|
||||||
var ourHeight = Window.innerHeight;
|
var ourHeight = Window.innerHeight;
|
||||||
var text = "placeholder";
|
|
||||||
var ctrlIsPressed = false;
|
var ctrlIsPressed = false;
|
||||||
var ready = true;
|
var ready = true;
|
||||||
var MENU_NAME = 'Tools > Notifications';
|
var MENU_NAME = 'Tools > Notifications';
|
||||||
|
@ -97,12 +97,14 @@ var NotificationType = {
|
||||||
WINDOW_RESIZE: 3,
|
WINDOW_RESIZE: 3,
|
||||||
LOD_WARNING: 4,
|
LOD_WARNING: 4,
|
||||||
CONNECTION_REFUSED: 5,
|
CONNECTION_REFUSED: 5,
|
||||||
|
EDIT_ERROR: 6,
|
||||||
properties: [
|
properties: [
|
||||||
{ text: "Mute Toggle" },
|
{ text: "Mute Toggle" },
|
||||||
{ text: "Snapshot" },
|
{ text: "Snapshot" },
|
||||||
{ text: "Window Resize" },
|
{ text: "Window Resize" },
|
||||||
{ text: "Level of Detail" },
|
{ text: "Level of Detail" },
|
||||||
{ text: "Connection Refused" }
|
{ text: "Connection Refused" },
|
||||||
|
{ text: "Edit error" }
|
||||||
],
|
],
|
||||||
getTypeFromMenuItem: function(menuItemName) {
|
getTypeFromMenuItem: function(menuItemName) {
|
||||||
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
|
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
|
||||||
|
@ -253,6 +255,9 @@ function notify(notice, button, height, imageProperties, image) {
|
||||||
|
|
||||||
positions = calculate3DOverlayPositions(noticeWidth, noticeHeight, notice.y);
|
positions = calculate3DOverlayPositions(noticeWidth, noticeHeight, notice.y);
|
||||||
|
|
||||||
|
notice.parentID = MyAvatar.sessionUUID;
|
||||||
|
notice.parentJointIndex = -2;
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
notice.topMargin = 0.75 * notice.topMargin * NOTIFICATION_3D_SCALE;
|
notice.topMargin = 0.75 * notice.topMargin * NOTIFICATION_3D_SCALE;
|
||||||
notice.leftMargin = 2 * notice.leftMargin * NOTIFICATION_3D_SCALE;
|
notice.leftMargin = 2 * notice.leftMargin * NOTIFICATION_3D_SCALE;
|
||||||
|
@ -270,6 +275,8 @@ function notify(notice, button, height, imageProperties, image) {
|
||||||
button.url = button.imageURL;
|
button.url = button.imageURL;
|
||||||
button.scale = button.width * NOTIFICATION_3D_SCALE;
|
button.scale = button.width * NOTIFICATION_3D_SCALE;
|
||||||
button.isFacingAvatar = false;
|
button.isFacingAvatar = false;
|
||||||
|
button.parentID = MyAvatar.sessionUUID;
|
||||||
|
button.parentJointIndex = -2;
|
||||||
|
|
||||||
buttons.push((Overlays.addOverlay("image3d", button)));
|
buttons.push((Overlays.addOverlay("image3d", button)));
|
||||||
overlay3DDetails.push({
|
overlay3DDetails.push({
|
||||||
|
@ -279,6 +286,34 @@ function notify(notice, button, height, imageProperties, image) {
|
||||||
width: noticeWidth,
|
width: noticeWidth,
|
||||||
height: noticeHeight
|
height: noticeHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var defaultEyePosition,
|
||||||
|
avatarOrientation,
|
||||||
|
notificationPosition,
|
||||||
|
notificationOrientation,
|
||||||
|
buttonPosition;
|
||||||
|
|
||||||
|
if (isOnHMD && notifications.length > 0) {
|
||||||
|
// Update 3D overlays to maintain positions relative to avatar
|
||||||
|
defaultEyePosition = MyAvatar.getDefaultEyePosition();
|
||||||
|
avatarOrientation = MyAvatar.orientation;
|
||||||
|
|
||||||
|
for (i = 0; i < notifications.length; i += 1) {
|
||||||
|
notificationPosition = Vec3.sum(defaultEyePosition,
|
||||||
|
Vec3.multiplyQbyV(avatarOrientation,
|
||||||
|
overlay3DDetails[i].notificationPosition));
|
||||||
|
notificationOrientation = Quat.multiply(avatarOrientation,
|
||||||
|
overlay3DDetails[i].notificationOrientation);
|
||||||
|
buttonPosition = Vec3.sum(defaultEyePosition,
|
||||||
|
Vec3.multiplyQbyV(avatarOrientation,
|
||||||
|
overlay3DDetails[i].buttonPosition));
|
||||||
|
Overlays.editOverlay(notifications[i], { position: notificationPosition,
|
||||||
|
rotation: notificationOrientation });
|
||||||
|
Overlays.editOverlay(buttons[i], { position: buttonPosition, rotation: notificationOrientation });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!image) {
|
if (!image) {
|
||||||
notificationText = Overlays.addOverlay("text", notice);
|
notificationText = Overlays.addOverlay("text", notice);
|
||||||
|
@ -429,11 +464,6 @@ function update() {
|
||||||
noticeOut,
|
noticeOut,
|
||||||
buttonOut,
|
buttonOut,
|
||||||
arraysOut,
|
arraysOut,
|
||||||
defaultEyePosition,
|
|
||||||
avatarOrientation,
|
|
||||||
notificationPosition,
|
|
||||||
notificationOrientation,
|
|
||||||
buttonPosition,
|
|
||||||
positions,
|
positions,
|
||||||
i,
|
i,
|
||||||
j,
|
j,
|
||||||
|
@ -457,7 +487,8 @@ function update() {
|
||||||
Overlays.editOverlay(notifications[i], { x: overlayLocationX, y: locationY });
|
Overlays.editOverlay(notifications[i], { x: overlayLocationX, y: locationY });
|
||||||
Overlays.editOverlay(buttons[i], { x: buttonLocationX, y: locationY + 12.0 });
|
Overlays.editOverlay(buttons[i], { x: buttonLocationX, y: locationY + 12.0 });
|
||||||
if (isOnHMD) {
|
if (isOnHMD) {
|
||||||
positions = calculate3DOverlayPositions(overlay3DDetails[i].width, overlay3DDetails[i].height, locationY);
|
positions = calculate3DOverlayPositions(overlay3DDetails[i].width,
|
||||||
|
overlay3DDetails[i].height, locationY);
|
||||||
overlay3DDetails[i].notificationOrientation = positions.notificationOrientation;
|
overlay3DDetails[i].notificationOrientation = positions.notificationOrientation;
|
||||||
overlay3DDetails[i].notificationPosition = positions.notificationPosition;
|
overlay3DDetails[i].notificationPosition = positions.notificationPosition;
|
||||||
overlay3DDetails[i].buttonPosition = positions.buttonPosition;
|
overlay3DDetails[i].buttonPosition = positions.buttonPosition;
|
||||||
|
@ -480,22 +511,6 @@ function update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOnHMD && notifications.length > 0) {
|
|
||||||
// Update 3D overlays to maintain positions relative to avatar
|
|
||||||
defaultEyePosition = MyAvatar.getDefaultEyePosition();
|
|
||||||
avatarOrientation = MyAvatar.orientation;
|
|
||||||
|
|
||||||
for (i = 0; i < notifications.length; i += 1) {
|
|
||||||
notificationPosition = Vec3.sum(defaultEyePosition,
|
|
||||||
Vec3.multiplyQbyV(avatarOrientation, overlay3DDetails[i].notificationPosition));
|
|
||||||
notificationOrientation = Quat.multiply(avatarOrientation, overlay3DDetails[i].notificationOrientation);
|
|
||||||
buttonPosition = Vec3.sum(defaultEyePosition,
|
|
||||||
Vec3.multiplyQbyV(avatarOrientation, overlay3DDetails[i].buttonPosition));
|
|
||||||
Overlays.editOverlay(notifications[i], { position: notificationPosition, rotation: notificationOrientation });
|
|
||||||
Overlays.editOverlay(buttons[i], { position: buttonPosition, rotation: notificationOrientation });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var STARTUP_TIMEOUT = 500, // ms
|
var STARTUP_TIMEOUT = 500, // ms
|
||||||
|
@ -532,12 +547,17 @@ function onDomainConnectionRefused(reason) {
|
||||||
createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED);
|
createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onEditError(msg) {
|
||||||
|
createNotification(wordWrap(msg), NotificationType.EDIT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function onSnapshotTaken(path, notify) {
|
function onSnapshotTaken(path, notify) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
var imageProperties = {
|
var imageProperties = {
|
||||||
path: "file:///" + path,
|
path: "file:///" + path,
|
||||||
aspectRatio: Window.innerWidth / Window.innerHeight
|
aspectRatio: Window.innerWidth / Window.innerHeight
|
||||||
}
|
};
|
||||||
createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties);
|
createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,8 +591,6 @@ function keyReleaseEvent(key) {
|
||||||
|
|
||||||
// Triggers notification on specific key driven events
|
// Triggers notification on specific key driven events
|
||||||
function keyPressEvent(key) {
|
function keyPressEvent(key) {
|
||||||
var noteString;
|
|
||||||
|
|
||||||
if (key.key === 16777249) {
|
if (key.key === 16777249) {
|
||||||
ctrlIsPressed = true;
|
ctrlIsPressed = true;
|
||||||
}
|
}
|
||||||
|
@ -622,13 +640,13 @@ function menuItemEvent(menuItem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LODManager.LODDecreased.connect(function() {
|
LODManager.LODDecreased.connect(function() {
|
||||||
var warningText = "\n"
|
var warningText = "\n" +
|
||||||
+ "Due to the complexity of the content, the \n"
|
"Due to the complexity of the content, the \n" +
|
||||||
+ "level of detail has been decreased. "
|
"level of detail has been decreased. " +
|
||||||
+ "You can now see: \n"
|
"You can now see: \n" +
|
||||||
+ LODManager.getLODFeedbackText();
|
LODManager.getLODFeedbackText();
|
||||||
|
|
||||||
if (lodTextID == false) {
|
if (lodTextID === false) {
|
||||||
lodTextID = createNotification(warningText, NotificationType.LOD_WARNING);
|
lodTextID = createNotification(warningText, NotificationType.LOD_WARNING);
|
||||||
} else {
|
} else {
|
||||||
Overlays.editOverlay(lodTextID, { text: warningText });
|
Overlays.editOverlay(lodTextID, { text: warningText });
|
||||||
|
@ -644,6 +662,7 @@ Script.scriptEnding.connect(scriptEnding);
|
||||||
Menu.menuItemEvent.connect(menuItemEvent);
|
Menu.menuItemEvent.connect(menuItemEvent);
|
||||||
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
|
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
|
||||||
Window.snapshotTaken.connect(onSnapshotTaken);
|
Window.snapshotTaken.connect(onSnapshotTaken);
|
||||||
|
Window.notifyEditError = onEditError;
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue