Browse Source

Fixing managed slerp code, and reordered some menu items

BearishSun 10 years ago
parent
commit
f0a0e1d9dd

+ 279 - 279
MBansheeEditor/BuildWindow.cs

@@ -1,279 +1,279 @@
-using System;
-using BansheeEngine;
-
-namespace BansheeEditor
-{
-    /// <summary>
-    /// Provides options for customizing and activating the build process which will output an executable of the game for a 
-    /// specific platform, as well as any required resources.
-    /// </summary>
-    [DefaultSize(500, 300)]
-    internal sealed class BuildWindow : EditorWindow
-    {
-        private static readonly Color PLATFORM_BG_COLOR = new Color(33.0f / 255.0f, 33.0f / 255.0f, 33.0f / 255.0f);
-
-        private PlatformType selectedPlatform;
-        private GUIScrollArea optionsScrollArea;
-        private ulong buildScheduledFrame = ulong.MaxValue;
-
-        private GUIToggle[] platformButtons;
-
-        /// <summary>
-        /// Opens the build window if its not open already.
-        /// </summary>
-        [MenuItem("Tools/Build", ButtonModifier.CtrlAlt, ButtonCode.B, 9296)]
-        private static void OpenBuildWindow()
-        {
-            OpenWindow<BuildWindow>();
-        }
-
-        /// <inheritdoc/>
-        protected override LocString GetDisplayName()
-        {
-            return new LocEdString("Build");
-        }
-
-        private void OnInitialize()
-        {
-            GUILayoutX splitLayout = GUI.AddLayoutX();
-            GUIPanel platformPanel = splitLayout.AddPanel();
-            GUIPanel platformForeground = platformPanel.AddPanel();
-            GUILayoutY platformLayout = platformForeground.AddLayoutY();
-            GUIPanel platformBackground = platformPanel.AddPanel(1);
-            GUITexture background = new GUITexture(Builtin.WhiteTexture);
-            background.SetTint(PLATFORM_BG_COLOR);
-
-            splitLayout.AddSpace(5);
-            GUILayoutY optionsLayout = splitLayout.AddLayoutY();
-
-            GUILabel platformsLabel = new GUILabel(new LocEdString("Platforms"), EditorStyles.LabelCentered);
-            platformLayout.AddSpace(5);
-            platformLayout.AddElement(platformsLabel);
-            platformLayout.AddSpace(5);
-
-            GUIToggleGroup platformToggleGroup = new GUIToggleGroup();
-
-            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
-            platformButtons = new GUIToggle[availablePlatforms.Length];
-            for (int i = 0; i < availablePlatforms.Length; i++)
-            {
-                PlatformType currentPlatform = availablePlatforms[i];
-                bool isActive = currentPlatform == BuildManager.ActivePlatform;
-
-                string platformName = Enum.GetName(typeof(PlatformType), currentPlatform);
-                if (isActive)
-                    platformName += " (Active)";
-
-                GUIToggle platformToggle = new GUIToggle(new LocEdString(platformName), platformToggleGroup, EditorStyles.Button);
-                platformToggle.OnToggled += x => OnSelectedPlatformChanged(currentPlatform, x);
-                platformLayout.AddElement(platformToggle);
-
-                platformButtons[i] = platformToggle;
-
-                if (isActive)
-                {
-                    platformToggle.Value = true;
-                    selectedPlatform = currentPlatform;
-                }
-            }
-
-            platformLayout.AddFlexibleSpace();
-
-            GUIButton changePlatformBtn = new GUIButton(new LocEdString("Set active"));
-            platformLayout.AddElement(changePlatformBtn);
-            changePlatformBtn.OnClick += ChangeActivePlatform;
-
-            platformBackground.AddElement(background);
-
-            optionsScrollArea = new GUIScrollArea();
-            optionsLayout.AddElement(optionsScrollArea);
-
-            GUIButton buildButton = new GUIButton(new LocEdString("Build"));
-            optionsLayout.AddFlexibleSpace();
-            optionsLayout.AddElement(buildButton);
-
-            buildButton.OnClick += TryStartBuild;
-
-            BuildPlatformOptionsGUI();
-        }
-
-        private void OnEditorUpdate()
-        {
-            if (buildScheduledFrame == Time.FrameIdx)
-            {
-                BuildManager.Build();
-                ProgressBar.Hide();
-
-                EditorApplication.OpenExternally(BuildManager.OutputFolder);
-                DialogBox.Open(new LocEdString("Build complete"), new LocEdString("Build complete"), DialogBox.Type.OK);
-            }
-        }
-
-        /// <summary>
-        /// Changes the currently selected platform. Be aware that while platform is selected and you may build for it,
-        /// it will not be made the active platform.
-        /// </summary>
-        /// <param name="type">Platform that was selected or deselected.</param>
-        /// <param name="selected">True if the platform was selected, false otherwise.</param>
-        private void OnSelectedPlatformChanged(PlatformType type, bool selected)
-        {
-            if (selected)
-            {
-                selectedPlatform = type;
-                BuildPlatformOptionsGUI();
-            }
-        }
-
-        /// <summary>
-        /// Changes the currently active build platform.
-        /// </summary>
-        private void ChangeActivePlatform()
-        {
-            BuildManager.ActivePlatform = selectedPlatform;
-
-            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
-            for (int i = 0; i < availablePlatforms.Length; i++)
-            {
-                PlatformType currentPlatform = availablePlatforms[i];
-                bool isActive = currentPlatform == BuildManager.ActivePlatform;
-
-                string platformName = Enum.GetName(typeof (PlatformType), currentPlatform);
-                if (isActive)
-                    platformName += " (Active)";
-
-                platformButtons[i].SetContent(new LocEdString(platformName));
-            }
-        }
-
-        /// <summary>
-        /// (Re)creates GUI with platform-specific options.
-        /// </summary>
-        private void BuildPlatformOptionsGUI()
-        {
-            optionsScrollArea.Layout.Clear();
-            GUILayout layout = optionsScrollArea.Layout;
-
-            PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform);
-
-            GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered);
-
-            GUIResourceField sceneField = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene"));
-            GUIToggleField debugToggle = new GUIToggleField(new LocEdString("Debug"));
-            
-            GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen"));
-            GUIIntField widthField = new GUIIntField(new LocEdString("Window width"));
-            GUIIntField heightField = new GUIIntField(new LocEdString("Window height"));
-
-            GUITextField definesField = new GUITextField(new LocEdString("Defines"));
-
-            layout.AddSpace(5);
-            layout.AddElement(options);
-            layout.AddSpace(5);
-            layout.AddElement(sceneField);
-            layout.AddElement(debugToggle);
-            layout.AddElement(fullscreenField);
-            layout.AddElement(widthField);
-            layout.AddElement(heightField);
-            layout.AddSpace(5);
-            layout.AddElement(definesField);
-            layout.AddSpace(5);
-
-            sceneField.ValueRef = platformInfo.MainScene;
-            debugToggle.Value = platformInfo.Debug;
-            definesField.Value = platformInfo.Defines;
-            fullscreenField.Value = platformInfo.Fullscreen;
-            widthField.Value = platformInfo.WindowedWidth;
-            heightField.Value = platformInfo.WindowedHeight;
-
-            if (platformInfo.Fullscreen)
-            {
-                widthField.Active = false;
-                heightField.Active = false;
-            }
-
-            sceneField.OnChanged += x => platformInfo.MainScene = x;
-            debugToggle.OnChanged += x => platformInfo.Debug = x;
-            definesField.OnChanged += x => platformInfo.Defines = x;
-            fullscreenField.OnChanged += x =>
-            {
-                widthField.Active = !x;
-                heightField.Active = !x;
-
-                platformInfo.Fullscreen = x;
-            };
-            widthField.OnChanged += x => platformInfo.WindowedWidth = x;
-            heightField.OnChanged += x => platformInfo.WindowedHeight = x;
-
-            switch (platformInfo.Type)
-            {
-                case PlatformType.Windows:
-                {
-                    WinPlatformInfo winPlatformInfo = (WinPlatformInfo) platformInfo;
-
-                    GUITextField titleField = new GUITextField(new LocEdString("Title"));
-
-                    layout.AddElement(titleField);
-                    layout.AddSpace(5);
-
-                    GUITextureField iconField = new GUITextureField(new LocEdString("Icon"));
-                    layout.AddElement(iconField);
-
-                    titleField.Value = winPlatformInfo.TitleText;
-                    iconField.ValueRef = winPlatformInfo.Icon;
-
-                    titleField.OnChanged += x => winPlatformInfo.TitleText = x;
-                    iconField.OnChanged += x => winPlatformInfo.Icon = x;
-                }
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Starts the build process for the currently selected platform.
-        /// </summary>
-        private void Build()
-        {
-            ProgressBar.Show(new LocEdString("Building..."), 0.0f);
-
-            EditorApplication.SaveProject();
-            // HACK - Delay build one frame so that progress bar has a chance to show. Use coroutines here once implemented.
-            buildScheduledFrame = Time.FrameIdx + 1;
-        }
-
-        /// <summary>
-        /// Attempts to save the current scene, and keeps retrying if failed or until user cancels.
-        /// </summary>
-        private void TrySaveScene()
-        {
-            EditorApplication.SaveScene(Build, TrySaveScene);
-        }
-
-        /// <summary>
-        /// Attempts to start the build process if user confirms.
-        /// </summary>
-        private void TryStartBuild()
-        {
-            Action<DialogBox.ResultType> dialogCallback =
-            (result) =>
-            {
-                if (result == DialogBox.ResultType.Yes)
-                    TrySaveScene();
-                else if (result == DialogBox.ResultType.No)
-                {
-                    EditorApplication.SaveProject();
-                    EditorApplication.Quit();
-                }
-            };
-
-            if (EditorApplication.IsSceneModified())
-            {
-                DialogBox.Open("Warning", "You current scene has modifications. Do you wish to save them first?",
-                    DialogBox.Type.YesNoCancel, dialogCallback);
-            }
-            else
-            {
-                Build();
-            }
-        }
-    }
-}
+using System;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /// <summary>
+    /// Provides options for customizing and activating the build process which will output an executable of the game for a 
+    /// specific platform, as well as any required resources.
+    /// </summary>
+    [DefaultSize(500, 300)]
+    internal sealed class BuildWindow : EditorWindow
+    {
+        private static readonly Color PLATFORM_BG_COLOR = new Color(33.0f / 255.0f, 33.0f / 255.0f, 33.0f / 255.0f);
+
+        private PlatformType selectedPlatform;
+        private GUIScrollArea optionsScrollArea;
+        private ulong buildScheduledFrame = ulong.MaxValue;
+
+        private GUIToggle[] platformButtons;
+
+        /// <summary>
+        /// Opens the build window if its not open already.
+        /// </summary>
+        [MenuItem("Tools/Build", ButtonModifier.CtrlAlt, ButtonCode.B, 9249)]
+        private static void OpenBuildWindow()
+        {
+            OpenWindow<BuildWindow>();
+        }
+
+        /// <inheritdoc/>
+        protected override LocString GetDisplayName()
+        {
+            return new LocEdString("Build");
+        }
+
+        private void OnInitialize()
+        {
+            GUILayoutX splitLayout = GUI.AddLayoutX();
+            GUIPanel platformPanel = splitLayout.AddPanel();
+            GUIPanel platformForeground = platformPanel.AddPanel();
+            GUILayoutY platformLayout = platformForeground.AddLayoutY();
+            GUIPanel platformBackground = platformPanel.AddPanel(1);
+            GUITexture background = new GUITexture(Builtin.WhiteTexture);
+            background.SetTint(PLATFORM_BG_COLOR);
+
+            splitLayout.AddSpace(5);
+            GUILayoutY optionsLayout = splitLayout.AddLayoutY();
+
+            GUILabel platformsLabel = new GUILabel(new LocEdString("Platforms"), EditorStyles.LabelCentered);
+            platformLayout.AddSpace(5);
+            platformLayout.AddElement(platformsLabel);
+            platformLayout.AddSpace(5);
+
+            GUIToggleGroup platformToggleGroup = new GUIToggleGroup();
+
+            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
+            platformButtons = new GUIToggle[availablePlatforms.Length];
+            for (int i = 0; i < availablePlatforms.Length; i++)
+            {
+                PlatformType currentPlatform = availablePlatforms[i];
+                bool isActive = currentPlatform == BuildManager.ActivePlatform;
+
+                string platformName = Enum.GetName(typeof(PlatformType), currentPlatform);
+                if (isActive)
+                    platformName += " (Active)";
+
+                GUIToggle platformToggle = new GUIToggle(new LocEdString(platformName), platformToggleGroup, EditorStyles.Button);
+                platformToggle.OnToggled += x => OnSelectedPlatformChanged(currentPlatform, x);
+                platformLayout.AddElement(platformToggle);
+
+                platformButtons[i] = platformToggle;
+
+                if (isActive)
+                {
+                    platformToggle.Value = true;
+                    selectedPlatform = currentPlatform;
+                }
+            }
+
+            platformLayout.AddFlexibleSpace();
+
+            GUIButton changePlatformBtn = new GUIButton(new LocEdString("Set active"));
+            platformLayout.AddElement(changePlatformBtn);
+            changePlatformBtn.OnClick += ChangeActivePlatform;
+
+            platformBackground.AddElement(background);
+
+            optionsScrollArea = new GUIScrollArea();
+            optionsLayout.AddElement(optionsScrollArea);
+
+            GUIButton buildButton = new GUIButton(new LocEdString("Build"));
+            optionsLayout.AddFlexibleSpace();
+            optionsLayout.AddElement(buildButton);
+
+            buildButton.OnClick += TryStartBuild;
+
+            BuildPlatformOptionsGUI();
+        }
+
+        private void OnEditorUpdate()
+        {
+            if (buildScheduledFrame == Time.FrameIdx)
+            {
+                BuildManager.Build();
+                ProgressBar.Hide();
+
+                EditorApplication.OpenExternally(BuildManager.OutputFolder);
+                DialogBox.Open(new LocEdString("Build complete"), new LocEdString("Build complete"), DialogBox.Type.OK);
+            }
+        }
+
+        /// <summary>
+        /// Changes the currently selected platform. Be aware that while platform is selected and you may build for it,
+        /// it will not be made the active platform.
+        /// </summary>
+        /// <param name="type">Platform that was selected or deselected.</param>
+        /// <param name="selected">True if the platform was selected, false otherwise.</param>
+        private void OnSelectedPlatformChanged(PlatformType type, bool selected)
+        {
+            if (selected)
+            {
+                selectedPlatform = type;
+                BuildPlatformOptionsGUI();
+            }
+        }
+
+        /// <summary>
+        /// Changes the currently active build platform.
+        /// </summary>
+        private void ChangeActivePlatform()
+        {
+            BuildManager.ActivePlatform = selectedPlatform;
+
+            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
+            for (int i = 0; i < availablePlatforms.Length; i++)
+            {
+                PlatformType currentPlatform = availablePlatforms[i];
+                bool isActive = currentPlatform == BuildManager.ActivePlatform;
+
+                string platformName = Enum.GetName(typeof (PlatformType), currentPlatform);
+                if (isActive)
+                    platformName += " (Active)";
+
+                platformButtons[i].SetContent(new LocEdString(platformName));
+            }
+        }
+
+        /// <summary>
+        /// (Re)creates GUI with platform-specific options.
+        /// </summary>
+        private void BuildPlatformOptionsGUI()
+        {
+            optionsScrollArea.Layout.Clear();
+            GUILayout layout = optionsScrollArea.Layout;
+
+            PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform);
+
+            GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered);
+
+            GUIResourceField sceneField = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene"));
+            GUIToggleField debugToggle = new GUIToggleField(new LocEdString("Debug"));
+            
+            GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen"));
+            GUIIntField widthField = new GUIIntField(new LocEdString("Window width"));
+            GUIIntField heightField = new GUIIntField(new LocEdString("Window height"));
+
+            GUITextField definesField = new GUITextField(new LocEdString("Defines"));
+
+            layout.AddSpace(5);
+            layout.AddElement(options);
+            layout.AddSpace(5);
+            layout.AddElement(sceneField);
+            layout.AddElement(debugToggle);
+            layout.AddElement(fullscreenField);
+            layout.AddElement(widthField);
+            layout.AddElement(heightField);
+            layout.AddSpace(5);
+            layout.AddElement(definesField);
+            layout.AddSpace(5);
+
+            sceneField.ValueRef = platformInfo.MainScene;
+            debugToggle.Value = platformInfo.Debug;
+            definesField.Value = platformInfo.Defines;
+            fullscreenField.Value = platformInfo.Fullscreen;
+            widthField.Value = platformInfo.WindowedWidth;
+            heightField.Value = platformInfo.WindowedHeight;
+
+            if (platformInfo.Fullscreen)
+            {
+                widthField.Active = false;
+                heightField.Active = false;
+            }
+
+            sceneField.OnChanged += x => platformInfo.MainScene = x;
+            debugToggle.OnChanged += x => platformInfo.Debug = x;
+            definesField.OnChanged += x => platformInfo.Defines = x;
+            fullscreenField.OnChanged += x =>
+            {
+                widthField.Active = !x;
+                heightField.Active = !x;
+
+                platformInfo.Fullscreen = x;
+            };
+            widthField.OnChanged += x => platformInfo.WindowedWidth = x;
+            heightField.OnChanged += x => platformInfo.WindowedHeight = x;
+
+            switch (platformInfo.Type)
+            {
+                case PlatformType.Windows:
+                {
+                    WinPlatformInfo winPlatformInfo = (WinPlatformInfo) platformInfo;
+
+                    GUITextField titleField = new GUITextField(new LocEdString("Title"));
+
+                    layout.AddElement(titleField);
+                    layout.AddSpace(5);
+
+                    GUITextureField iconField = new GUITextureField(new LocEdString("Icon"));
+                    layout.AddElement(iconField);
+
+                    titleField.Value = winPlatformInfo.TitleText;
+                    iconField.ValueRef = winPlatformInfo.Icon;
+
+                    titleField.OnChanged += x => winPlatformInfo.TitleText = x;
+                    iconField.OnChanged += x => winPlatformInfo.Icon = x;
+                }
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// Starts the build process for the currently selected platform.
+        /// </summary>
+        private void Build()
+        {
+            ProgressBar.Show(new LocEdString("Building..."), 0.0f);
+
+            EditorApplication.SaveProject();
+            // HACK - Delay build one frame so that progress bar has a chance to show. Use coroutines here once implemented.
+            buildScheduledFrame = Time.FrameIdx + 1;
+        }
+
+        /// <summary>
+        /// Attempts to save the current scene, and keeps retrying if failed or until user cancels.
+        /// </summary>
+        private void TrySaveScene()
+        {
+            EditorApplication.SaveScene(Build, TrySaveScene);
+        }
+
+        /// <summary>
+        /// Attempts to start the build process if user confirms.
+        /// </summary>
+        private void TryStartBuild()
+        {
+            Action<DialogBox.ResultType> dialogCallback =
+            (result) =>
+            {
+                if (result == DialogBox.ResultType.Yes)
+                    TrySaveScene();
+                else if (result == DialogBox.ResultType.No)
+                {
+                    EditorApplication.SaveProject();
+                    EditorApplication.Quit();
+                }
+            };
+
+            if (EditorApplication.IsSceneModified())
+            {
+                DialogBox.Open("Warning", "You current scene has modifications. Do you wish to save them first?",
+                    DialogBox.Type.YesNoCancel, dialogCallback);
+            }
+            else
+            {
+                Build();
+            }
+        }
+    }
+}

+ 1 - 1
MBansheeEditor/Scene/SceneWindow.cs

@@ -100,7 +100,7 @@ namespace BansheeEditor
         /// <summary>
         /// Focuses on the currently selected object.
         /// </summary>
-        [MenuItem("Tools/Frame Selected", ButtonModifier.None, ButtonCode.F, 9296, true)]
+        [MenuItem("Tools/Frame Selected", ButtonModifier.None, ButtonCode.F, 9275, true)]
         private static void OpenSettingsWindow()
         {
             SceneWindow window = GetWindow<SceneWindow>();

+ 101 - 101
MBansheeEditor/SettingsWindow.cs

@@ -1,101 +1,101 @@
-using System;
-using BansheeEngine;
-
-namespace BansheeEditor
-{
-    /// <summary>
-    /// Displays project and editor settings.
-    /// </summary>
-    [DefaultSize(300, 200)]
-    internal sealed class SettingsWindow : EditorWindow
-    {
-        internal const string ActiveCodeEditorKey = "__ActiveCodeEditor";
-
-        private GUIFloatField defaultHandleSizeField;
-        private GUIToggleField autoLoadLastProjectField;
-        private GUIListBoxField codeEditorField;
-
-        /// <summary>
-        /// Opens the settings window if its not open already.
-        /// </summary>
-        [MenuItem("Tools/Settings", 9297, true)]
-        private static void OpenSettingsWindow()
-        {
-            OpenWindow<SettingsWindow>();
-        }
-
-        /// <inheritdoc/>
-        protected override LocString GetDisplayName()
-        {
-            return new LocEdString("Settings");
-        }
-
-        private void OnInitialize()
-        {
-            GUIToggle projectFoldout = new GUIToggle(new LocEdString("Project"), EditorStyles.Foldout);
-            GUIToggle editorFoldout = new GUIToggle(new LocEdString("Editor"), EditorStyles.Foldout);
-
-            defaultHandleSizeField = new GUIFloatField(new LocEdString("Handle size"), 200);
-            defaultHandleSizeField.OnChanged += (x) => { EditorSettings.DefaultHandleSize = x; };
-
-            autoLoadLastProjectField = new GUIToggleField(new LocEdString("Automatically load last project"), 200);
-            autoLoadLastProjectField.OnChanged += (x) => { EditorSettings.AutoLoadLastProject = x; };
-
-            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
-            Array.Resize(ref availableEditors, availableEditors.Length + 1);
-            availableEditors[availableEditors.Length - 1] = CodeEditorType.None;
-
-            string[] availableEditorNames = new string[availableEditors.Length];
-            for (int i = 0; i < availableEditors.Length; i++)
-                availableEditorNames[i] = Enum.GetName(typeof (CodeEditorType), availableEditors[i]);
-
-            codeEditorField = new GUIListBoxField(availableEditorNames, new LocEdString("Code editor"), 200);
-            codeEditorField.OnSelectionChanged += x =>
-            {
-                EditorSettings.SetInt(ActiveCodeEditorKey, (int)availableEditors[x]);
-                CodeEditor.ActiveEditor = availableEditors[x];
-            };
-
-            GUILayout mainLayout = GUI.AddLayoutY();
-            mainLayout.AddElement(projectFoldout);
-            GUILayout projectLayoutOuterY = mainLayout.AddLayoutY();
-            projectLayoutOuterY.AddSpace(5);
-            GUILayout projectLayoutOuterX = projectLayoutOuterY.AddLayoutX();
-            projectLayoutOuterX.AddSpace(5);
-            GUILayout projectLayout = projectLayoutOuterX.AddLayoutY();
-            projectLayoutOuterX.AddSpace(5);
-            projectLayoutOuterY.AddSpace(5);
-
-            mainLayout.AddElement(editorFoldout);
-            GUILayout editorLayoutOuterY = mainLayout.AddLayoutY();
-            editorLayoutOuterY.AddSpace(5);
-            GUILayout editorLayoutOuterX = editorLayoutOuterY.AddLayoutX();
-            editorLayoutOuterX.AddSpace(5);
-            GUILayout editorLayout = editorLayoutOuterX.AddLayoutY();
-            editorLayoutOuterX.AddSpace(5);
-            editorLayoutOuterY.AddSpace(5);
-
-            mainLayout.AddFlexibleSpace();
-
-            editorLayout.AddElement(defaultHandleSizeField);
-            editorLayout.AddElement(autoLoadLastProjectField);
-
-            projectFoldout.Value = true;
-            editorFoldout.Value = true;
-
-            projectFoldout.OnToggled += (x) => projectLayout.Active = x;
-            editorFoldout.OnToggled += (x) => editorLayout.Active = x;
-        }
-
-        private void OnEditorUpdate()
-        {
-            defaultHandleSizeField.Value = EditorSettings.DefaultHandleSize;
-            autoLoadLastProjectField.Value = EditorSettings.AutoLoadLastProject;
-
-            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
-            int idx = Array.IndexOf(availableEditors, CodeEditor.ActiveEditor);
-            if (idx != -1)
-                codeEditorField.Index = idx;
-        }
-    }
-}
+using System;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /// <summary>
+    /// Displays project and editor settings.
+    /// </summary>
+    [DefaultSize(300, 200)]
+    internal sealed class SettingsWindow : EditorWindow
+    {
+        internal const string ActiveCodeEditorKey = "__ActiveCodeEditor";
+
+        private GUIFloatField defaultHandleSizeField;
+        private GUIToggleField autoLoadLastProjectField;
+        private GUIListBoxField codeEditorField;
+
+        /// <summary>
+        /// Opens the settings window if its not open already.
+        /// </summary>
+        [MenuItem("Tools/Settings", 9250, true)]
+        private static void OpenSettingsWindow()
+        {
+            OpenWindow<SettingsWindow>();
+        }
+
+        /// <inheritdoc/>
+        protected override LocString GetDisplayName()
+        {
+            return new LocEdString("Settings");
+        }
+
+        private void OnInitialize()
+        {
+            GUIToggle projectFoldout = new GUIToggle(new LocEdString("Project"), EditorStyles.Foldout);
+            GUIToggle editorFoldout = new GUIToggle(new LocEdString("Editor"), EditorStyles.Foldout);
+
+            defaultHandleSizeField = new GUIFloatField(new LocEdString("Handle size"), 200);
+            defaultHandleSizeField.OnChanged += (x) => { EditorSettings.DefaultHandleSize = x; };
+
+            autoLoadLastProjectField = new GUIToggleField(new LocEdString("Automatically load last project"), 200);
+            autoLoadLastProjectField.OnChanged += (x) => { EditorSettings.AutoLoadLastProject = x; };
+
+            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
+            Array.Resize(ref availableEditors, availableEditors.Length + 1);
+            availableEditors[availableEditors.Length - 1] = CodeEditorType.None;
+
+            string[] availableEditorNames = new string[availableEditors.Length];
+            for (int i = 0; i < availableEditors.Length; i++)
+                availableEditorNames[i] = Enum.GetName(typeof (CodeEditorType), availableEditors[i]);
+
+            codeEditorField = new GUIListBoxField(availableEditorNames, new LocEdString("Code editor"), 200);
+            codeEditorField.OnSelectionChanged += x =>
+            {
+                EditorSettings.SetInt(ActiveCodeEditorKey, (int)availableEditors[x]);
+                CodeEditor.ActiveEditor = availableEditors[x];
+            };
+
+            GUILayout mainLayout = GUI.AddLayoutY();
+            mainLayout.AddElement(projectFoldout);
+            GUILayout projectLayoutOuterY = mainLayout.AddLayoutY();
+            projectLayoutOuterY.AddSpace(5);
+            GUILayout projectLayoutOuterX = projectLayoutOuterY.AddLayoutX();
+            projectLayoutOuterX.AddSpace(5);
+            GUILayout projectLayout = projectLayoutOuterX.AddLayoutY();
+            projectLayoutOuterX.AddSpace(5);
+            projectLayoutOuterY.AddSpace(5);
+
+            mainLayout.AddElement(editorFoldout);
+            GUILayout editorLayoutOuterY = mainLayout.AddLayoutY();
+            editorLayoutOuterY.AddSpace(5);
+            GUILayout editorLayoutOuterX = editorLayoutOuterY.AddLayoutX();
+            editorLayoutOuterX.AddSpace(5);
+            GUILayout editorLayout = editorLayoutOuterX.AddLayoutY();
+            editorLayoutOuterX.AddSpace(5);
+            editorLayoutOuterY.AddSpace(5);
+
+            mainLayout.AddFlexibleSpace();
+
+            editorLayout.AddElement(defaultHandleSizeField);
+            editorLayout.AddElement(autoLoadLastProjectField);
+
+            projectFoldout.Value = true;
+            editorFoldout.Value = true;
+
+            projectFoldout.OnToggled += (x) => projectLayout.Active = x;
+            editorFoldout.OnToggled += (x) => editorLayout.Active = x;
+        }
+
+        private void OnEditorUpdate()
+        {
+            defaultHandleSizeField.Value = EditorSettings.DefaultHandleSize;
+            autoLoadLastProjectField.Value = EditorSettings.AutoLoadLastProject;
+
+            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
+            int idx = Array.IndexOf(availableEditors, CodeEditor.ActiveEditor);
+            if (idx != -1)
+                codeEditorField.Index = idx;
+        }
+    }
+}

+ 6 - 6
MBansheeEngine/Math/Quaternion.cs

@@ -396,12 +396,12 @@ namespace BansheeEngine
         /// <paramref name="to"/>.</returns>
         public static Quaternion Slerp(Quaternion from, Quaternion to, float t, bool shortestPath = true)
         {
-            float cos = from.w*to.w + from.x*to.x + from.y*to.y + from.z*from.z;
+            float dot = Dot(from, to);
             Quaternion quat;
 
-            if (cos < 0.0f && shortestPath)
+            if (dot < 0.0f && shortestPath)
             {
-                cos = -cos;
+                dot = -dot;
                 quat = -to;
             }
             else
@@ -409,10 +409,10 @@ namespace BansheeEngine
                 quat = to;
             }
 
-            if (MathEx.Abs(cos) < (1 - epsilon))
+            if (MathEx.Abs(dot) < (1 - epsilon))
             {
-                float sin = MathEx.Sqrt(1 - (cos*cos));
-                float angle = MathEx.Atan2(sin, cos);
+                float sin = MathEx.Sqrt(1 - (dot*dot));
+                float angle = MathEx.Atan2(sin, dot);
                 float invSin = 1.0f / sin;
                 float a = MathEx.Sin((1.0f - t) * angle) * invSin;
                 float b = MathEx.Sin(t * angle) * invSin;