Procházet zdrojové kódy

Animation events editor working

BearishSun před 9 roky
rodič
revize
3a4610eef9

+ 4 - 4
Source/BansheeEditor/Source/BsGUISceneTreeView.cpp

@@ -94,10 +94,10 @@ namespace BansheeEngine
 
 
 			HSceneObject currentSOChild = currentSO->getChild(i);
 			HSceneObject currentSOChild = currentSO->getChild(i);
 
 
-//#if BS_DEBUG_MODE == 0
+#if BS_DEBUG_MODE == 0
 			if (currentSOChild->hasFlag(SOF_Internal))
 			if (currentSOChild->hasFlag(SOF_Internal))
 				continue;
 				continue;
-//#endif
+#endif
 
 
 			SceneTreeElement* currentChild = static_cast<SceneTreeElement*>(element->mChildren[visibleChildCount]);
 			SceneTreeElement* currentChild = static_cast<SceneTreeElement*>(element->mChildren[visibleChildCount]);
 			visibleChildCount++;
 			visibleChildCount++;
@@ -132,10 +132,10 @@ namespace BansheeEngine
 				// Only count it as a prefab instance if its not scene root (otherwise every object would be colored as a prefab)
 				// Only count it as a prefab instance if its not scene root (otherwise every object would be colored as a prefab)
 				bool isPrefabInstance = prefabParent != nullptr && prefabParent->getParent() != nullptr;
 				bool isPrefabInstance = prefabParent != nullptr && prefabParent->getParent() != nullptr;
 
 
-//#if BS_DEBUG_MODE == 0
+#if BS_DEBUG_MODE == 0
 				if (isInternal)
 				if (isInternal)
 					continue;
 					continue;
-//#endif
+#endif
 
 
 				UINT64 curId = currentSOChild->getInstanceId();
 				UINT64 curId = currentSOChild->getInstanceId();
 				bool found = false;
 				bool found = false;

+ 6 - 5
Source/MBansheeEditor/Windows/Animation/GUIAnimEvents.cs

@@ -48,14 +48,15 @@ namespace BansheeEditor
                 return false;
                 return false;
             }
             }
 
 
-            Vector2I relativeCoords = pixelCoords - new Vector2I(bounds.x + PADDING, bounds.y);
+            Vector2I relativeCoords = pixelCoords - new Vector2I(bounds.x, bounds.y);
             for (int i = 0; i < events.Length; i++)
             for (int i = 0; i < events.Length; i++)
             {
             {
                 AnimationEvent evnt = events[i];
                 AnimationEvent evnt = events[i];
 
 
                 int xPos = (int)(((evnt.Time - rangeOffset) / GetRange()) * drawableWidth) + PADDING;
                 int xPos = (int)(((evnt.Time - rangeOffset) / GetRange()) * drawableWidth) + PADDING;
 
 
-                if (relativeCoords.x >= (xPos - EVENT_HALF_WIDTH) || relativeCoords.y >= (xPos + EVENT_HALF_WIDTH))
+                Debug.Log(i + ". " + xPos);
+                if (relativeCoords.x >= (xPos - EVENT_HALF_WIDTH) && relativeCoords.x <= (xPos + EVENT_HALF_WIDTH))
                 {
                 {
                     eventIdx = i;
                     eventIdx = i;
                     return true;
                     return true;
@@ -98,10 +99,10 @@ namespace BansheeEditor
         {
         {
             int xPos = (int)(((t - rangeOffset) / GetRange()) * drawableWidth) + PADDING;
             int xPos = (int)(((t - rangeOffset) / GetRange()) * drawableWidth) + PADDING;
 
 
-            Vector2I a = new Vector2I(xPos - EVENT_HALF_WIDTH, height - 1);
-            Vector2I b = new Vector2I(xPos, 0);
+            Vector2I a = new Vector2I(xPos - EVENT_HALF_WIDTH, 0);
+            Vector2I b = new Vector2I(xPos + EVENT_HALF_WIDTH, 0);
             Vector2I c = new Vector2I(xPos + EVENT_HALF_WIDTH, height - 1);
             Vector2I c = new Vector2I(xPos + EVENT_HALF_WIDTH, height - 1);
-            Vector2I d = new Vector2I(xPos, 0);
+            Vector2I d = new Vector2I(xPos - EVENT_HALF_WIDTH, height - 1);
 
 
             // Draw square shape
             // Draw square shape
             Vector2I[] linePoints = { a, b, c, d, a };
             Vector2I[] linePoints = { a, b, c, d, a };

+ 24 - 11
Source/MBansheeEditor/Windows/Animation/GUICurveEditor.cs

@@ -354,7 +354,7 @@ namespace BansheeEditor
                     else
                     else
                     {
                     {
                         int eventIdx;
                         int eventIdx;
-                        if (guiEvents.FindEvent(pointerPos, out eventIdx))
+                        if (guiEvents.FindEvent(eventPos, out eventIdx))
                         {
                         {
                             if (!Input.IsButtonHeld(ButtonCode.LeftShift) && !Input.IsButtonHeld(ButtonCode.RightShift))
                             if (!Input.IsButtonHeld(ButtonCode.LeftShift) && !Input.IsButtonHeld(ButtonCode.RightShift))
                                 ClearSelection();
                                 ClearSelection();
@@ -362,6 +362,13 @@ namespace BansheeEditor
                             events[eventIdx].selected = true;
                             events[eventIdx].selected = true;
                             UpdateEventsGUI();
                             UpdateEventsGUI();
                         }
                         }
+                        else
+                        {
+                            ClearSelection();
+
+                            guiCurveDrawing.Rebuild();
+                            UpdateEventsGUI();
+                        }
                     }
                     }
 
 
                     OnFrameSelected?.Invoke(frameIdx);
                     OnFrameSelected?.Invoke(frameIdx);
@@ -406,7 +413,7 @@ namespace BansheeEditor
                     contextClickPosition = eventPos;
                     contextClickPosition = eventPos;
 
 
                     int eventIdx;
                     int eventIdx;
-                    if (guiEvents.FindEvent(eventPos, out eventIdx))
+                    if (!guiEvents.FindEvent(eventPos, out eventIdx))
                     {
                     {
                         ClearSelection();
                         ClearSelection();
 
 
@@ -978,9 +985,9 @@ namespace BansheeEditor
 
 
             Vector2I position = new Vector2I();
             Vector2I position = new Vector2I();
             position.x = guiEvents.GetOffset(animEvent.Time);
             position.x = guiEvents.GetOffset(animEvent.Time);
-            position.y = height/2;
+            position.y = EVENTS_HEIGHT/2;
 
 
-            Rect2I eventBounds = eventsPanel.Bounds;
+            Rect2I eventBounds = GUIUtility.CalculateBounds(eventsPanel, window.GUI);
             Vector2I windowPos = position + new Vector2I(eventBounds.x, eventBounds.y);
             Vector2I windowPos = position + new Vector2I(eventBounds.x, eventBounds.y);
 
 
             EventEditWindow editWindow = DropDownWindow.Open<EventEditWindow>(window, windowPos);
             EventEditWindow editWindow = DropDownWindow.Open<EventEditWindow>(window, windowPos);
@@ -994,7 +1001,7 @@ namespace BansheeEditor
     /// <summary>
     /// <summary>
     /// Drop down window that displays input boxes used for editing an event.
     /// Drop down window that displays input boxes used for editing an event.
     /// </summary>
     /// </summary>
-    [DefaultSize(70, 50)]
+    [DefaultSize(200, 50)]
     internal class EventEditWindow : DropDownWindow
     internal class EventEditWindow : DropDownWindow
     {
     {
         /// <summary>
         /// <summary>
@@ -1005,13 +1012,13 @@ namespace BansheeEditor
         /// <param name="updateCallback">Callback triggered when event values change.</param>
         /// <param name="updateCallback">Callback triggered when event values change.</param>
         internal void Initialize(AnimationEvent animEvent, Action updateCallback)
         internal void Initialize(AnimationEvent animEvent, Action updateCallback)
         {
         {
-            GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40);
+            GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40, "");
             timeField.Value = animEvent.Time;
             timeField.Value = animEvent.Time;
-            timeField.OnChanged += x => { animEvent.Time = x; }; // TODO UNDOREDO  
+            timeField.OnChanged += x => { animEvent.Time = x; updateCallback(); }; // TODO UNDOREDO  
 
 
-            GUITextField methodField = new GUITextField(new LocEdString("Method"), 40);
+            GUITextField methodField = new GUITextField(new LocEdString("Method"), 40, false, "", GUIOption.FixedWidth(190));
             methodField.Value = animEvent.Name;
             methodField.Value = animEvent.Name;
-            methodField.OnChanged += x => { animEvent.Name = x; }; // TODO UNDOREDO 
+            methodField.OnChanged += x => { animEvent.Name = x; updateCallback(); }; // TODO UNDOREDO 
 
 
             GUILayoutY vertLayout = GUI.AddLayoutY();
             GUILayoutY vertLayout = GUI.AddLayoutY();
 
 
@@ -1019,8 +1026,14 @@ namespace BansheeEditor
             GUILayoutX horzLayout = vertLayout.AddLayoutX();
             GUILayoutX horzLayout = vertLayout.AddLayoutX();
             horzLayout.AddFlexibleSpace();
             horzLayout.AddFlexibleSpace();
             GUILayout contentLayout = horzLayout.AddLayoutY();
             GUILayout contentLayout = horzLayout.AddLayoutY();
-            contentLayout.AddElement(timeField);
-            contentLayout.AddElement(methodField);
+            GUILayout timeLayout = contentLayout.AddLayoutX();
+            timeLayout.AddSpace(5);
+            timeLayout.AddElement(timeField);
+            timeLayout.AddFlexibleSpace();
+            GUILayout methodLayout = contentLayout.AddLayoutX();
+            methodLayout.AddSpace(5);
+            methodLayout.AddElement(methodField);
+            methodLayout.AddFlexibleSpace();
             horzLayout.AddFlexibleSpace();
             horzLayout.AddFlexibleSpace();
             vertLayout.AddFlexibleSpace();
             vertLayout.AddFlexibleSpace();
         }
         }