Explorar o código

Added mouse sensitivity slider to editor

BearishSun %!s(int64=10) %!d(string=hai) anos
pai
achega
f9665210a2

+ 14 - 1
BansheeEditor/Include/BsEditorSettings.h

@@ -60,6 +60,12 @@ namespace BansheeEngine
 		/** Retrieves the maximum number of frames per second the editor is allowed to execute. Zero means infinite. */
 		UINT32 getFPSLimit() const { return mFPSLimit; }
 
+		/** 
+		 * Retrieves a value that controls sensitivity of mouse movements. This doesn't apply to mouse cursor. 
+		 * Default value is 1.0f.
+		 */
+		float getMouseSensitivity() const { return mMouseSensitivity; }
+
 		/**	Enables/disables snapping for move handles in scene view. */
 		void setMoveHandleSnapActive(bool snapActive) { mMoveSnapActive = snapActive; markAsDirty(); }
 
@@ -100,7 +106,13 @@ namespace BansheeEngine
 		void setRecentProjects(const Vector<RecentProject>& value) { mRecentProjects = value; markAsDirty(); }
 
 		/** Sets the maximum number of frames per second the editor is allowed to execute. Zero means infinite. */
-		void setFPSLimit(UINT32 limit) { mFPSLimit = limit; }
+		void setFPSLimit(UINT32 limit) { mFPSLimit = limit; markAsDirty(); }
+
+		/** 
+		 * Sets a value that controls sensitivity of mouse movements. This doesn't apply to mouse cursor. 
+		 * Default value is 1.0f.
+		 */
+		void setMouseSensitivity(float value) { mMouseSensitivity = value; markAsDirty(); }
 
 	private:
 		bool mMoveSnapActive;
@@ -118,6 +130,7 @@ namespace BansheeEngine
 
 		float mHandleSize;
 		UINT32 mFPSLimit;
+		float mMouseSensitivity;
 
 		Path mLastOpenProject;
 		bool mAutoLoadLastProject;

+ 2 - 0
BansheeEditor/Include/BsEditorSettingsRTTI.h

@@ -31,6 +31,7 @@ namespace BansheeEngine
 		BS_PLAIN_MEMBER(mRecentProjects);
 
 		BS_PLAIN_MEMBER(mFPSLimit);
+		BS_PLAIN_MEMBER(mMouseSensitivity);
 
 	public:
 		EditorSettingsRTTI()
@@ -55,6 +56,7 @@ namespace BansheeEngine
 			BS_ADD_PLAIN_FIELD(mRecentProjects, 12);
 
 			BS_ADD_PLAIN_FIELD(mFPSLimit, 13);
+			BS_ADD_PLAIN_FIELD(mMouseSensitivity, 14);
 		}
 
 		virtual const String& getRTTIName() override

+ 1 - 1
BansheeEditor/Source/BsEditorSettings.cpp

@@ -8,7 +8,7 @@ namespace BansheeEngine
 	EditorSettings::EditorSettings()
 		:mMoveSnapActive(false), mRotateSnapActive(false), mMoveSnap(0.1f), mRotationSnap(20.0f),
 		mGridSize(256), mGridAxisSpacing(1.0f), mHandleSize(0.10f), mActiveSceneTool(1 /* Move */),
-		mActiveCoordinateMode(0), mActivePivotMode(0), mFPSLimit(60)
+		mActiveCoordinateMode(0), mActivePivotMode(0), mFPSLimit(60), mMouseSensitivity(1.0f)
 	{ }
 	
 	RTTITypeBase* EditorSettings::getRTTIStatic()

+ 1 - 13
BansheeUtility/Include/Win32/BsWin32Window.h

@@ -110,6 +110,7 @@ namespace BansheeEngine
 
 		/** Called when window is moved or resized externally. */
 		void _windowMovedOrResized();
+
 	private:
 		friend class Win32WindowManager;
 
@@ -121,19 +122,6 @@ namespace BansheeEngine
 		static Mutex sWindowsMutex;
 	};
 
-	/** Tracks all created Windows windows. */
-	class BS_UTILITY_EXPORT Win32WindowManager
-	{
-		/** Should be called whenever a new window is created. */
-		static void _registerWindow(Win32Window* window);
-
-		/** Should be called just before a window is destroyed. */
-		static void _unregisterWindow(Win32Window* window);
-
-		///** Enables all windows that are currently disabled (don't accept mouse and keyboard input) */
-		//static void _enableAllWindows();
-	};
-
 	/** @} */
 	/** @endcond */
 }

+ 1 - 0
BansheeUtility/Source/Win32/BsWin32BrowseDialogs.cpp

@@ -152,6 +152,7 @@ namespace BansheeEngine
 		}
 
 		CoUninitialize();
+
 		return finalResult;
 	}
 }

+ 15 - 0
MBansheeEditor/EditorSettings.cs

@@ -102,6 +102,16 @@ namespace BansheeEditor
             set { Internal_SetFPSLimit(value); }
         }
 
+        /// <summary>
+        /// Controls sensitivity of mouse movements in the editor. This doesn't apply to mouse cursor.
+        /// Default value is 1.0f.
+        /// </summary>
+        public static float MouseSensitivity
+        {
+            get { return Internal_GetMouseSensitivity(); }
+            set { Internal_SetMouseSensitivity(value); }
+        }
+
         /// <summary>
         /// Contains the absolute path to the last open project, if any.
         /// </summary>
@@ -331,6 +341,11 @@ namespace BansheeEditor
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetFPSLimit(int value);
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern float Internal_GetMouseSensitivity();
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetMouseSensitivity(float value);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern string Internal_GetLastOpenProject();
         [MethodImpl(MethodImplOptions.InternalCall)]

+ 4 - 2
MBansheeEditor/Scene/SceneCamera.cs

@@ -193,8 +193,10 @@ namespace BansheeEditor
                     float horzValue = VirtualInput.GetAxisValue(horizontalAxis);
                     float vertValue = VirtualInput.GetAxisValue(verticalAxis);
 
-                    yaw += new Degree(horzValue*RotationalSpeed*frameDelta);
-                    pitch += new Degree(vertValue*RotationalSpeed*frameDelta);
+                    float rotationAmount = RotationalSpeed * EditorSettings.MouseSensitivity * frameDelta;
+
+                    yaw += new Degree(horzValue * rotationAmount);
+                    pitch += new Degree(vertValue * rotationAmount);
 
                     yaw = MathEx.WrapAngle(yaw);
                     pitch = MathEx.WrapAngle(pitch);

+ 6 - 0
MBansheeEditor/SettingsWindow.cs

@@ -17,6 +17,7 @@ namespace BansheeEditor
         private GUIToggleField autoLoadLastProjectField;
         private GUIListBoxField codeEditorField;
         private GUIIntField fpsLimitField;
+        private GUISliderField mouseSensitivityField;
 
         /// <summary>
         /// Opens the settings window if its not open already.
@@ -63,6 +64,9 @@ namespace BansheeEditor
             fpsLimitField.OnConfirmed += () => EditorSettings.FPSLimit = fpsLimitField.Value;
             fpsLimitField.OnFocusLost += () => EditorSettings.FPSLimit = fpsLimitField.Value;
 
+            mouseSensitivityField = new GUISliderField(0.2f, 2.0f, new LocEdString("Mouse sensitivity"));
+            mouseSensitivityField.OnChanged += (x) => EditorSettings.MouseSensitivity = x;
+
             GUILayout mainLayout = GUI.AddLayoutY();
             mainLayout.AddElement(projectFoldout);
             GUILayout projectLayoutOuterY = mainLayout.AddLayoutY();
@@ -88,6 +92,7 @@ namespace BansheeEditor
             editorLayout.AddElement(autoLoadLastProjectField);
             editorLayout.AddElement(codeEditorField);
             editorLayout.AddElement(fpsLimitField);
+            editorLayout.AddElement(mouseSensitivityField);
 
             projectFoldout.Value = true;
             editorFoldout.Value = true;
@@ -101,6 +106,7 @@ namespace BansheeEditor
             defaultHandleSizeField.Value = EditorSettings.DefaultHandleSize;
             autoLoadLastProjectField.Value = EditorSettings.AutoLoadLastProject;
             fpsLimitField.Value = EditorSettings.FPSLimit;
+            mouseSensitivityField.Value = EditorSettings.MouseSensitivity;
 
             CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
             int idx = Array.IndexOf(availableEditors, CodeEditor.ActiveEditor);

+ 29 - 29
README.md

@@ -130,7 +130,7 @@ Aside from Banshee source code you will also need various third party dependenci
 
 ## Getting started
 
-Banshee is a multi-layered engine that aims to be flexible enough to handle various needs. Therefore this section is split into two sub-sections, first one aimed for game developers (high-level C# programmers, artists, designers) and engine developers (low level C++ programmers).
+Banshee is a multi-layered engine that aims to be flexible enough to handle various needs. Therefore this section is split into two sub-sections, first one aimed for game developers (high-level C# programmers, artists, designers) and second one for engine developers (low level C++ programmers).
 
 ### Getting started (Game developers)
 
@@ -186,7 +186,7 @@ Easiest way to get started is to check out the [video guide] (http:://TODO). The
 	camera = cameraSO.AddComponent<Camera>();
 	camera.NearClipPlane = 0.05f;
 	camera.FarClipPlane = 2500.0f;
-	camera.ClearColor = ClearColor;
+	camera.ClearColor = Color.Black;
 
 	cameraSO.Position = new Vector3(0, 0, 5);
 	cameraSO.LookAt(new Vector3(0, 0, 0));
@@ -220,58 +220,58 @@ Easiest way to get started with low-level Banshee programming is to check out th
 
 #### Starting a minimal application
 ```
-  RENDER_WINDOW_DESC renderWindowDesc;
-  renderWindowDesc.videoMode = VideoMode(1280, 720);
-  renderWindowDesc.title = "My App";
-  renderWindowDesc.fullscreen = false;
+	RENDER_WINDOW_DESC renderWindowDesc;
+	renderWindowDesc.videoMode = VideoMode(1280, 720);
+	renderWindowDesc.title = "My App";
+	renderWindowDesc.fullscreen = false;
 	
-  Application::startUp(renderWindowDesc, RenderSystemPlugin::DX11);
-  Application::instance().runMainLoop();
-  Application::shutDown();
+	Application::startUp(renderWindowDesc, RenderSystemPlugin::DX11);
+	Application::instance().runMainLoop();
+	Application::shutDown();
 ```
 
 #### Importing resources
 ```
-  HMesh dragonModel = gImporter().import<Mesh>("Dragon.fbx");
-  HTexture dragonTexture = gImporter().import<Texture>("Dragon.psd");
+	HMesh dragonModel = gImporter().import<Mesh>("Dragon.fbx");
+	HTexture dragonTexture = gImporter().import<Texture>("Dragon.psd");
 ```
 
 #### Adding and positioning a camera
 ```
-  HSceneObject sceneCameraSO = SceneObject::create("SceneCamera");
-  HCamera sceneCamera = sceneCameraSO->addComponent<CCamera>(window);
+	HSceneObject sceneCameraSO = SceneObject::create("SceneCamera");
+	HCamera sceneCamera = sceneCameraSO->addComponent<CCamera>(window);
 
-  sceneCameraSO->setPosition(Vector3(40.0f, 30.0f, 230.0f));
-  sceneCameraSO->lookAt(Vector3(0, 0, 0));
+	sceneCameraSO->setPosition(Vector3(40.0f, 30.0f, 230.0f));
+	sceneCameraSO->lookAt(Vector3(0, 0, 0));
 ```
 
 #### Setting up a material
 ```
-   HShader diffuse = gImporter().import<Shader>("Diffuse.bsl");
-   HMaterial dragonMaterial = Material::create(diffuse);
+	HShader diffuse = gImporter().import<Shader>("Diffuse.bsl");
+	HMaterial dragonMaterial = Material::create(diffuse);
    
-   dragonMaterial->setTexture("albedo", dragonTexture);
+	dragonMaterial->setTexture("albedo", dragonTexture);
 ```
 
 #### Adding an object for rendering
 ```
-  HSceneObject dragonSO = SceneObject::create("Dragon");
+	HSceneObject dragonSO = SceneObject::create("Dragon");
   
-  HRenderable renderable = dragonSO->addComponent<CRenderable>();
-  renderable->setMesh(dragonModel);
-  renderable->setMaterial(dragonMaterial);
+	HRenderable renderable = dragonSO->addComponent<CRenderable>();
+	renderable->setMesh(dragonModel);
+	renderable->setMaterial(dragonMaterial);
 ```
 
 #### Adding GUI
 ```
-  HSceneObject guiSO = SceneObject::create("GUI");
-  HCamera guiCamera = guiSO->addComponent<CCamera>(window);
-  HGUIWidget gui = guiSO->addComponent<CGUIWidget>(guiCamera);
+	HSceneObject guiSO = SceneObject::create("GUI");
+	HCamera guiCamera = guiSO->addComponent<CCamera>(window);
+	HGUIWidget gui = guiSO->addComponent<CGUIWidget>(guiCamera);
   
-  GUIPanel* guiPanel = gui->getPanel();
-  GUILayout* guiLayout = guiPanel->addNewElement<GUILayoutY>();
-  guiLayout->addNewElement<GUIButton>(HString(L"Click me!"));
-  guiLayout->addNewElement<GUIButton>(HString(L"Click me too!"));
+	GUIPanel* guiPanel = gui->getPanel();
+	GUILayout* guiLayout = guiPanel->addNewElement<GUILayoutY>();
+	guiLayout->addNewElement<GUIButton>(HString(L"Click me!"));
+	guiLayout->addNewElement<GUIButton>(HString(L"Click me too!"));
 ```
 
 # License

+ 2 - 0
SBansheeEditor/Include/BsScriptEditorSettings.h

@@ -39,6 +39,8 @@ namespace BansheeEngine
 		static void internal_SetActivePivotMode(UINT32 value);
 		static UINT32 internal_GetFPSLimit();
 		static void internal_SetFPSLimit(UINT32 value);
+		static float internal_GetMouseSensitivity();
+		static void internal_SetMouseSensitivity(float value);
 
 		static MonoString* internal_GetLastOpenProject();
 		static void internal_SetLastOpenProject(MonoString* value);

+ 14 - 0
SBansheeEditor/Source/BsScriptEditorSettings.cpp

@@ -34,6 +34,8 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_SetActivePivotMode", &ScriptEditorSettings::internal_SetActivePivotMode);
 		metaData.scriptClass->addInternalCall("Internal_GetFPSLimit", &ScriptEditorSettings::internal_GetFPSLimit);
 		metaData.scriptClass->addInternalCall("Internal_SetFPSLimit", &ScriptEditorSettings::internal_SetFPSLimit);
+		metaData.scriptClass->addInternalCall("Internal_GetMouseSensitivity", &ScriptEditorSettings::internal_GetMouseSensitivity);
+		metaData.scriptClass->addInternalCall("Internal_SetMouseSensitivity", &ScriptEditorSettings::internal_SetMouseSensitivity);
 		metaData.scriptClass->addInternalCall("Internal_GetLastOpenProject", &ScriptEditorSettings::internal_GetLastOpenProject);
 		metaData.scriptClass->addInternalCall("Internal_SetLastOpenProject", &ScriptEditorSettings::internal_SetLastOpenProject);
 		metaData.scriptClass->addInternalCall("Internal_GetAutoLoadLastProject", &ScriptEditorSettings::internal_GetAutoLoadLastProject);
@@ -163,6 +165,18 @@ namespace BansheeEngine
 		settings->setFPSLimit(value);
 	}
 
+	float ScriptEditorSettings::internal_GetMouseSensitivity()
+	{
+		EditorSettingsPtr settings = gEditorApplication().getEditorSettings();
+		return settings->getMouseSensitivity();
+	}
+
+	void ScriptEditorSettings::internal_SetMouseSensitivity(float value)
+	{
+		EditorSettingsPtr settings = gEditorApplication().getEditorSettings();
+		settings->setMouseSensitivity(value);
+	}
+
 	MonoString* ScriptEditorSettings::internal_GetLastOpenProject()
 	{
 		EditorSettingsPtr settings = gEditorApplication().getEditorSettings();