AnimationWindow.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /** @addtogroup Windows
  7. * @{
  8. */
  9. /// <summary>
  10. /// Displays animation curve editor window.
  11. /// </summary>
  12. internal class AnimationWindow : EditorWindow
  13. {
  14. private GUITimeline timeline;
  15. private GUIFloatField startField;
  16. private GUIFloatField endField;
  17. private GUIIntField fpsField;
  18. /// <summary>
  19. /// Opens the animation window.
  20. /// </summary>
  21. [MenuItem("Windows/Animation", ButtonModifier.CtrlAlt, ButtonCode.A, 6000)]
  22. private static void OpenGameWindow()
  23. {
  24. OpenWindow<AnimationWindow>();
  25. }
  26. /// <inheritdoc/>
  27. protected override LocString GetDisplayName()
  28. {
  29. return new LocEdString("Animation");
  30. }
  31. private void OnInitialize()
  32. {
  33. startField = new GUIFloatField(new LocEdString("Start"), 50);
  34. endField = new GUIFloatField(new LocEdString("End"), 50);
  35. fpsField = new GUIIntField(new LocEdString("FPS"), 50);
  36. endField.Value = 60.0f;
  37. fpsField.Value = 1;
  38. startField.OnChanged += x => timeline.SetRange(x, endField.Value);
  39. endField.OnChanged += x => timeline.SetRange(startField.Value, x);
  40. fpsField.OnChanged += x => timeline.SetFPS(x);
  41. GUILayout buttonLayout = GUI.AddLayoutX();
  42. buttonLayout.AddElement(startField);
  43. buttonLayout.AddElement(endField);
  44. buttonLayout.AddElement(fpsField);
  45. timeline = new GUITimeline(GUI, Width, 20);
  46. }
  47. protected override void WindowResized(int width, int height)
  48. {
  49. timeline.SetSize(width, 20);
  50. }
  51. private void OnEditorUpdate()
  52. {
  53. //int position = (int)(MathEx.Sin(Time.RealElapsed)*50.0f + 50.0f);
  54. //canvas.SetPosition(position, 0);
  55. }
  56. private void OnDestroy()
  57. {
  58. // TODO
  59. }
  60. }
  61. /** @} */
  62. }