Program.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Entry point to the editor.
  8. /// </summary>
  9. class Program
  10. {
  11. private static EditorApplication app;
  12. /// <summary>
  13. /// Called by the runtime whenever the editor assembly is loaded. This means initially when editor is started
  14. /// and every time assembly refresh occurs.
  15. /// </summary>
  16. static void OnInitialize()
  17. {
  18. app = new EditorApplication();
  19. }
  20. /// <summary>
  21. /// Called by the runtime when the editor is first started. Called after <see cref="OnInitialize"/>.
  22. /// </summary>
  23. static void OnEditorLoad()
  24. {
  25. if (EditorSettings.AutoLoadLastProject)
  26. {
  27. string projectPath = EditorSettings.LastOpenProject;
  28. if (EditorApplication.IsValidProject(projectPath))
  29. EditorApplication.LoadProject(projectPath);
  30. else
  31. ProjectWindow.Open();
  32. }
  33. else
  34. ProjectWindow.Open();
  35. CodeEditorType activeCodeEditor = (CodeEditorType)EditorSettings.GetInt(SettingsWindow.ActiveCodeEditorKey, (int) CodeEditorType.None);
  36. CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
  37. if (Array.Exists(availableEditors, x => x == activeCodeEditor))
  38. CodeEditor.ActiveEditor = activeCodeEditor;
  39. else
  40. {
  41. if (availableEditors.Length > 0)
  42. CodeEditor.ActiveEditor = availableEditors[0];
  43. }
  44. }
  45. /// <summary>
  46. /// Called 60 times per second by the runtime.
  47. /// </summary>
  48. static void OnEditorUpdate()
  49. {
  50. app.OnEditorUpdate();
  51. }
  52. }
  53. }