Browse Source

Added shortcut key names for non alphanumeric keys
Creating a new element as a child of another element in Hierarchy view no longer crashes the program
Disallow parenting of a scene object to itself
When performing copy properly position the new elements as children of the currently selected element
Right clicking on tree view can no longer trigger rename if the element is already selected
Fixed a memory corruption issue with sampler overrides

Marko Pintera 10 years ago
parent
commit
4a4223c27e

+ 2 - 5
BansheeCore/Source/BsSceneObject.cpp

@@ -450,11 +450,8 @@ namespace BansheeEngine
 
 	void SceneObject::setParent(const HSceneObject& parent)
 	{
-		if(parent.isDestroyed())
-		{
-			BS_EXCEPT(InternalErrorException, 
-				"Trying to assign a SceneObject parent that is destroyed.");
-		}
+		if (parent.isDestroyed() || mThisHandle == parent)
+			return;
 
 		if(mParent == nullptr || mParent != parent)
 		{

+ 3 - 1
BansheeEditor/Source/BsGUISceneTreeView.cpp

@@ -545,7 +545,9 @@ namespace BansheeEngine
 			else
 				message = L"Copied " + toWString(mCopyList.size()) + L" elements";
 
-			CmdCloneSO::execute(mCopyList, message);
+			Vector<HSceneObject> clones = CmdCloneSO::execute(mCopyList, message);
+			for (auto& clone : clones)
+				clone->setParent(parent);
 		}
 	}
 

+ 74 - 60
BansheeEditor/Source/BsGUITreeView.cpp

@@ -227,96 +227,107 @@ namespace BansheeEngine
 
 				if (!onFoldout && !onEditElement)
 				{
-					if (event.isCtrlDown())
+					if (event.getButton() == GUIMouseButton::Left)
 					{
-						selectElement(treeElement);
-					}
-					else if (event.isShiftDown())
-					{
-						if (isSelectionActive())
+						if (event.isCtrlDown())
 						{
-							TreeElement* selectionRoot = mSelectedElements[0].element;
-							unselectAll();
-
-							auto iterStartFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
-								[&](const InteractableElement& x) { return x.parent == selectionRoot->mParent; });
-
-							bool foundStart = false;
-							bool foundEnd = false;
-							for (; iterStartFind != mVisibleElements.end(); ++iterStartFind)
+							selectElement(treeElement);
+						}
+						else if (event.isShiftDown())
+						{
+							if (isSelectionActive())
 							{
-								if (!iterStartFind->isTreeElement())
-									continue;
+								TreeElement* selectionRoot = mSelectedElements[0].element;
+								unselectAll();
+
+								auto iterStartFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
+									[&](const InteractableElement& x) { return x.parent == selectionRoot->mParent; });
 
-								TreeElement* curElem = iterStartFind->getTreeElement();
-								if (curElem == selectionRoot)
+								bool foundStart = false;
+								bool foundEnd = false;
+								for (; iterStartFind != mVisibleElements.end(); ++iterStartFind)
 								{
-									foundStart = true;
-									break;
+									if (!iterStartFind->isTreeElement())
+										continue;
+
+									TreeElement* curElem = iterStartFind->getTreeElement();
+									if (curElem == selectionRoot)
+									{
+										foundStart = true;
+										break;
+									}
 								}
-							}
 
-							auto iterEndFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
-								[&](const InteractableElement& x) { return &x == element; });
+								auto iterEndFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
+									[&](const InteractableElement& x) { return &x == element; });
 
-							if (iterEndFind != mVisibleElements.end())
-								foundEnd = true;
+								if (iterEndFind != mVisibleElements.end())
+									foundEnd = true;
 
-							if (foundStart && foundEnd)
-							{
-								if (iterStartFind < iterEndFind)
+								if (foundStart && foundEnd)
 								{
-									for (; iterStartFind != (iterEndFind + 1); ++iterStartFind)
+									if (iterStartFind < iterEndFind)
 									{
-										if (iterStartFind->isTreeElement())
-											selectElement(iterStartFind->getTreeElement());
+										for (; iterStartFind != (iterEndFind + 1); ++iterStartFind)
+										{
+											if (iterStartFind->isTreeElement())
+												selectElement(iterStartFind->getTreeElement());
+										}
 									}
-								}
-								else if (iterEndFind < iterStartFind)
-								{
-									for (; iterEndFind != (iterStartFind + 1); ++iterEndFind)
+									else if (iterEndFind < iterStartFind)
 									{
-										if (iterEndFind->isTreeElement())
-											selectElement(iterEndFind->getTreeElement());
+										for (; iterEndFind != (iterStartFind + 1); ++iterEndFind)
+										{
+											if (iterEndFind->isTreeElement())
+												selectElement(iterEndFind->getTreeElement());
+										}
 									}
+									else
+										selectElement(treeElement);
 								}
-								else
+
+								if (!foundStart || !foundEnd)
 									selectElement(treeElement);
 							}
-
-							if (!foundStart || !foundEnd)
+							else
+							{
 								selectElement(treeElement);
+							}
 						}
 						else
 						{
-							selectElement(treeElement);
-						}
-					}
-					else
-					{
-						bool doRename = false;
-						if (isSelectionActive())
-						{
-							for (auto& selectedElem : mSelectedElements)
+							bool doRename = false;
+							if (isSelectionActive())
 							{
-								if (selectedElem.element == treeElement)
+								for (auto& selectedElem : mSelectedElements)
 								{
-									doRename = true;
-									break;
+									if (selectedElem.element == treeElement)
+									{
+										doRename = true;
+										break;
+									}
 								}
 							}
+
+							unselectAll();
+							selectElement(treeElement);
+
+							if (doRename)
+								renameSelected();
 						}
 
+						_markLayoutAsDirty();
+
+						return true;
+					}
+					else if (event.getButton() == GUIMouseButton::Right)
+					{
 						unselectAll();
 						selectElement(treeElement);
+						_markLayoutAsDirty();
 
-						if (doRename)
-							renameSelected();
+						return true;
 					}
-
-					_markLayoutAsDirty();
-
-					return true;
 				}
 			}
 			else
@@ -675,11 +686,14 @@ namespace BansheeEngine
 		Stack<TreeElement*> todo;
 
 		TreeElement* parent = element->mParent;
-		while (parent != nullptr && !parent->mIsVisible)
+		while (parent != nullptr)
 		{
 			if (!parent->mIsExpanded)
 				todo.push(parent);
 
+			if (parent->mIsVisible)
+				break;
+
 			parent = parent->mParent;
 		}
 

+ 47 - 2
BansheeEngine/Source/BsShortcutKey.cpp

@@ -1,5 +1,7 @@
 #include "BsShortcutKey.h"
 #include "BsPlatform.h"
+#include "BsHEString.h"
+#include "BsHString.h"
 
 namespace BansheeEngine
 {
@@ -36,11 +38,54 @@ namespace BansheeEngine
 			L"Shift + Ctrl + Alt + "
 		};
 
+		static const UnorderedMap<ButtonCode, HEString> FUNCTION_KEY_TO_NAME =
+		{
+			{BC_ESCAPE, HEString(L"Escape")},
+			{BC_BACK, HEString(L"Backspace")},
+			{BC_TAB, HEString(L"Tab")},
+			{BC_RETURN, HEString(L"Return")},
+			{BC_SPACE, HEString(L"Space")},
+			{BC_CAPITAL, HEString(L"Caps Lock")},
+			{BC_F1, HEString(L"F1")},
+			{BC_F2, HEString(L"F2")},
+			{BC_F3, HEString(L"F3")},
+			{BC_F4, HEString(L"F4")},
+			{BC_F5, HEString(L"F5")},
+			{BC_F6, HEString(L"F6")},
+			{BC_F7, HEString(L"F7")},
+			{BC_F8, HEString(L"F8")},
+			{BC_F9, HEString(L"F9")},
+			{BC_F10, HEString(L"F10")},
+			{BC_F11, HEString(L"F11")},
+			{BC_F12, HEString(L"F12")},
+			{BC_DELETE, HEString(L"Delete")},
+			{BC_INSERT, HEString(L"Insert")},
+			{BC_UP, HEString(L"Up")},
+			{BC_LEFT, HEString(L"Left")},
+			{BC_RIGHT, HEString(L"Right")},
+			{BC_DOWN, HEString(L"Down")},
+			{BC_PGUP, HEString(L"Page Up")},
+			{BC_PGDOWN, HEString(L"Page Down")},
+			{BC_END, HEString(L"End")},
+			{BC_HOME, HEString(L"Home")},
+			{BC_PAUSE, HEString(L"Pause")},
+		};
+
 		if (button == BC_UNASSIGNED)
 			return L"";
 
-		WString charStr = Platform::keyCodeToUnicode((UINT32)button);
-		StringUtil::toUpperCase(charStr);
+		WString charStr;
+
+		auto iterFind = FUNCTION_KEY_TO_NAME.find(button);
+		if (iterFind != FUNCTION_KEY_TO_NAME.end())
+		{
+			charStr = ((HString)iterFind->second);
+		}
+		else
+		{
+			charStr = Platform::keyCodeToUnicode((UINT32)button);
+			StringUtil::toUpperCase(charStr);
+		}
 
 		return MODIFIER_TO_NAME[(UINT32)modifier] + charStr;
 	}

+ 1 - 1
BansheeRenderer/Source/BsSamplerOverrides.cpp

@@ -30,7 +30,7 @@ namespace BansheeEngine
 				for (auto iter = paramDesc.samplers.begin(); iter != paramDesc.samplers.end(); ++iter)
 				{
 					UINT32 slot = iter->second.slot;
-					maxSamplerSlot = std::max(maxSamplerSlot, slot);
+					maxSamplerSlot = std::max(maxSamplerSlot, slot + 1);
 				}
 
 				totalNumSamplerStates += maxSamplerSlot;

+ 2 - 4
TODO.txt

@@ -56,10 +56,8 @@ Polish
 
 SceneTreeView
  - When having scene window in focus and then right clicking on Hierarchy the cursor becomes invisible
- - Test: 
-    - Cut/Copy/Paste/duplicate/Delete
-    - Context menu
-    - Creating new objects
+ - Creating a new SO causes an exception
+ - Duplicating a mesh doesn't properly render the mesh
 
 Ribek use:
  - Camera, Renderable, Material, Texture inspector