|
|
@@ -22,6 +22,8 @@ namespace BansheeEditor
|
|
|
private int height;
|
|
|
private float xRange = 60.0f;
|
|
|
private float yRange = 20.0f;
|
|
|
+ private int fps = 1;
|
|
|
+ private int frameMarkerIdx = -1;
|
|
|
|
|
|
private int drawableWidth;
|
|
|
private GUICanvas canvas;
|
|
|
@@ -36,6 +38,49 @@ namespace BansheeEditor
|
|
|
SetSize(width, height);
|
|
|
}
|
|
|
|
|
|
+ public void SetCurves(EdAnimationCurve[] curves)
|
|
|
+ {
|
|
|
+ this.curves = curves;
|
|
|
+
|
|
|
+ Rebuild();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetSize(int width, int height)
|
|
|
+ {
|
|
|
+ this.width = width;
|
|
|
+ this.height = height;
|
|
|
+
|
|
|
+ canvas.SetWidth(width);
|
|
|
+ canvas.SetHeight(height);
|
|
|
+
|
|
|
+ drawableWidth = Math.Max(0, width - PADDING * 2);
|
|
|
+
|
|
|
+ Rebuild();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetRange(float xRange, float yRange)
|
|
|
+ {
|
|
|
+ this.xRange = xRange;
|
|
|
+ this.yRange = yRange;
|
|
|
+
|
|
|
+ Rebuild();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetFPS(int fps)
|
|
|
+ {
|
|
|
+ this.fps = Math.Max(1, fps);
|
|
|
+
|
|
|
+ Rebuild();
|
|
|
+ }
|
|
|
+
|
|
|
+ // Set to -1 to clear it
|
|
|
+ public void SetFrameMarker(int frameIdx)
|
|
|
+ {
|
|
|
+ frameMarkerIdx = frameIdx;
|
|
|
+
|
|
|
+ Rebuild();
|
|
|
+ }
|
|
|
+
|
|
|
public bool GetCurveCoordinates(Vector2I windowCoords, out Vector2 curveCoords)
|
|
|
{
|
|
|
Rect2I bounds = canvas.Bounds;
|
|
|
@@ -61,32 +106,22 @@ namespace BansheeEditor
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public void SetCurves(EdAnimationCurve[] curves)
|
|
|
- {
|
|
|
- this.curves = curves;
|
|
|
-
|
|
|
- Rebuild();
|
|
|
- }
|
|
|
-
|
|
|
- public void SetSize(int width, int height)
|
|
|
+ private void DrawFrameMarker(float t)
|
|
|
{
|
|
|
- this.width = width;
|
|
|
- this.height = height;
|
|
|
-
|
|
|
- canvas.SetWidth(width);
|
|
|
- canvas.SetHeight(height);
|
|
|
+ int xPos = (int)((t / GetRange()) * drawableWidth) + PADDING;
|
|
|
|
|
|
- drawableWidth = Math.Max(0, width - PADDING * 2);
|
|
|
+ Vector2I start = new Vector2I(xPos, 0);
|
|
|
+ Vector2I end = new Vector2I(xPos, height);
|
|
|
|
|
|
- Rebuild();
|
|
|
+ canvas.DrawLine(start, end, Color.Red);
|
|
|
}
|
|
|
|
|
|
- public void SetRange(float xRange, float yRange)
|
|
|
+ // Returns range rounded to the nearest multiple of FPS
|
|
|
+ private float GetRange()
|
|
|
{
|
|
|
- this.xRange = xRange;
|
|
|
- this.yRange = yRange;
|
|
|
+ float spf = 1.0f / fps;
|
|
|
|
|
|
- Rebuild();
|
|
|
+ return ((int)xRange / spf) * spf;
|
|
|
}
|
|
|
|
|
|
private void Rebuild()
|
|
|
@@ -104,6 +139,15 @@ namespace BansheeEditor
|
|
|
// TODO - Pick unique color for each curve
|
|
|
DrawCurve(curve, Color.Red);
|
|
|
}
|
|
|
+
|
|
|
+ // Draw frame marker
|
|
|
+ float range = GetRange();
|
|
|
+
|
|
|
+ int numFrames = (int)range * fps;
|
|
|
+ float timePerFrame = range / numFrames;
|
|
|
+
|
|
|
+ if (frameMarkerIdx != -1)
|
|
|
+ DrawFrameMarker(frameMarkerIdx * timePerFrame);
|
|
|
}
|
|
|
|
|
|
private void DrawCurve(EdAnimationCurve curve, Color color)
|