From d9f86612de72cb10004d70ae68db4e06669650fb Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 19 Feb 2017 20:18:11 +0200 Subject: [PATCH] Fixed view toggle, Added new Notifications - View Toggle now only toggles if no other modifiers are pressed - More notification, and cases for notification - Parenting to existing parent - Unparenting when there is no parent - Unparenting single entities --- interface/src/Application.cpp | 10 ++++--- scripts/system/edit.js | 54 ++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 488e97b5e6..bfc5be29e7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2886,10 +2886,12 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; case Qt::Key_P: { - bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson); - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked); - Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked); - cameraMenuChanged(); + if (!(isShifted || isMeta || isOption)) { + bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson); + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked); + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked); + cameraMenuChanged(); + } break; } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 61bbd23180..7731edd622 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1116,30 +1116,64 @@ function recursiveDelete(entities, childrenList) { } function unparentSelectedEntities() { if (SelectionManager.hasSelection()) { - var selectedEntities = selectionManager.selections; - selectedEntities.forEach(function (id, index) { - Entities.editEntity(id, {parentID: null}) - return true; - }); - Window.notify("Entities Unparented"); + var selectedEntities = selectionManager.selections; + var parentCheck = false; + + if (selectedEntities.length < 1) { + Window.notifyEditError("You must have an entity selected inorder to unparent it."); + return; + } + selectedEntities.forEach(function (id, index) { + var parentId = Entities.getEntityProperties(id, ["parentID"]).parentID; + if (parentId !== null && parentId.length > 0 && parentId !== "{00000000-0000-0000-0000-000000000000}") { + parentCheck = true; + } + Entities.editEntity(id, {parentID: null}) + return true; + }); + if (parentCheck) { + if (selectedEntities.length > 1) { + Window.notify("Entities unparented"); + } else { + Window.notify("Entity unparented"); + } + } else { + if (selectedEntities.length > 1) { + Window.notify("Selected Entities have no parents"); + } else { + Window.notify("Selected Entity does not have a parent"); + } + } + } else { + Window.notifyEditError("You have nothing selected to unparent"); } } function parentSelectedEntities() { if (SelectionManager.hasSelection()) { var selectedEntities = selectionManager.selections; if (selectedEntities.length <= 1) { - Window.notifyEditError("You must have multiple objects selected in order to parent them"); - return; + Window.notifyEditError("You must have multiple entities selected in order to parent them"); + return; } + var parentCheck = false; var lastEntityId = selectedEntities[selectedEntities.length-1]; selectedEntities.forEach(function (id, index) { if (lastEntityId !== id) { + var parentId = Entities.getEntityProperties(id, ["parentID"]).parentID; + if (parentId !== lastEntityId) { + parentCheck = true; + } Entities.editEntity(id, {parentID: lastEntityId}) } }); - Window.notify("Entities Parented"); + + if(parentCheck) { + Window.notify("Entities parented"); + }else { + Window.notify("Entities are already parented to last"); + } } else { - Window.notifyEditError("You have nothing selected") + Window.notifyEditError("You have nothing selected to parent"); } } function deleteSelectedEntities() {