From 34817446c083e249fae32a7c6ef930db5f90d6f7 Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Fri, 17 Jul 2009 07:57:28 +0000 Subject: [PATCH] Renamed WindowSettings to ContextSettings in SFML.Net Removed the Window.Events property in SFML.Net FS#124 - Fix KeyEvent.Alt/Control/Shift members not working, in SFML.Net git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1179 4e206d99-4929-0410-ac5d-dfc041789085 --- dotnet/src/Graphics/RenderWindow.cs | 18 ++++---- .../{WindowSettings.cs => ContextSettings.cs} | 8 ++-- dotnet/src/Window/Event.cs | 6 +-- dotnet/src/Window/EventArgs.cs | 6 +-- dotnet/src/Window/Window.cs | 41 +++++-------------- dotnet/src/Window/sfml-window.csproj | 4 +- 6 files changed, 32 insertions(+), 51 deletions(-) rename dotnet/src/Window/{WindowSettings.cs => ContextSettings.cs} (84%) diff --git a/dotnet/src/Graphics/RenderWindow.cs b/dotnet/src/Graphics/RenderWindow.cs index 6b9ec1db9..aec175024 100644 --- a/dotnet/src/Graphics/RenderWindow.cs +++ b/dotnet/src/Graphics/RenderWindow.cs @@ -25,7 +25,7 @@ namespace SFML /// Title of the window //////////////////////////////////////////////////////////// public RenderWindow(VideoMode mode, string title) : - this(mode, title, Styles.Resize | Styles.Close, new WindowSettings(24, 8, 0)) + this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8, 0)) { } @@ -38,7 +38,7 @@ namespace SFML /// Window style (Resize | Close by default) //////////////////////////////////////////////////////////// public RenderWindow(VideoMode mode, string title, Styles style) : - this(mode, title, style, new WindowSettings(24, 8, 0)) + this(mode, title, style, new ContextSettings(24, 8, 0)) { } @@ -51,7 +51,7 @@ namespace SFML /// Window style (Resize | Close by default) /// Creation parameters //////////////////////////////////////////////////////////// - public RenderWindow(VideoMode mode, string title, Styles style, WindowSettings settings) : + public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings) : base(sfRenderWindow_Create(mode, title, style, settings), 0) { Initialize(); @@ -64,7 +64,7 @@ namespace SFML /// Platform-specific handle of the control //////////////////////////////////////////////////////////// public RenderWindow(IntPtr handle) : - this(handle, new WindowSettings(24, 8, 0)) + this(handle, new ContextSettings(24, 8, 0)) { } @@ -75,7 +75,7 @@ namespace SFML /// Platform-specific handle of the control /// Creation parameters //////////////////////////////////////////////////////////// - public RenderWindow(IntPtr handle, WindowSettings settings) : + public RenderWindow(IntPtr handle, ContextSettings settings) : base(sfRenderWindow_CreateFromHandle(handle, settings), 0) { Initialize(); @@ -141,7 +141,7 @@ namespace SFML /// Creation settings of the window /// //////////////////////////////////////////////////////////// - public override WindowSettings Settings + public override ContextSettings Settings { get {return sfRenderWindow_GetSettings(This);} } @@ -460,10 +460,10 @@ namespace SFML #region Imports [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] - static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, WindowSettings Params); + static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, ContextSettings Params); [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] - static extern IntPtr sfRenderWindow_CreateFromHandle(IntPtr Handle, WindowSettings Params); + static extern IntPtr sfRenderWindow_CreateFromHandle(IntPtr Handle, ContextSettings Params); [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] static extern void sfRenderWindow_Destroy(IntPtr This); @@ -496,7 +496,7 @@ namespace SFML static extern uint sfRenderWindow_GetHeight(IntPtr This); [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] - static extern WindowSettings sfRenderWindow_GetSettings(IntPtr This); + static extern ContextSettings sfRenderWindow_GetSettings(IntPtr This); [DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity] static extern void sfRenderWindow_UseVerticalSync(IntPtr This, bool Enable); diff --git a/dotnet/src/Window/WindowSettings.cs b/dotnet/src/Window/ContextSettings.cs similarity index 84% rename from dotnet/src/Window/WindowSettings.cs rename to dotnet/src/Window/ContextSettings.cs index 375337178..a8c73269c 100644 --- a/dotnet/src/Window/WindowSettings.cs +++ b/dotnet/src/Window/ContextSettings.cs @@ -7,11 +7,11 @@ namespace SFML { //////////////////////////////////////////////////////////// /// - /// Structure defining the creation settings of windows + /// Structure defining the creation settings of OpenGL contexts /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] - public struct WindowSettings + public struct ContextSettings { //////////////////////////////////////////////////////////// /// @@ -20,7 +20,7 @@ namespace SFML /// Depth buffer bits /// Stencil buffer bits //////////////////////////////////////////////////////////// - public WindowSettings(uint depthBits, uint stencilBits) : + public ContextSettings(uint depthBits, uint stencilBits) : this(depthBits, stencilBits, 0) { } @@ -33,7 +33,7 @@ namespace SFML /// Stencil buffer bits /// Antialiasing level //////////////////////////////////////////////////////////// - public WindowSettings(uint depthBits, uint stencilBits, uint antialiasingLevel) + public ContextSettings(uint depthBits, uint stencilBits, uint antialiasingLevel) { DepthBits = depthBits; StencilBits = stencilBits; diff --git a/dotnet/src/Window/Event.cs b/dotnet/src/Window/Event.cs index 37a1043f2..543ada661 100644 --- a/dotnet/src/Window/Event.cs +++ b/dotnet/src/Window/Event.cs @@ -234,13 +234,13 @@ namespace SFML public KeyCode Code; /// Is the Alt modifier pressed? - public bool Alt; + public int Alt; /// Is the Control modifier pressed? - public bool Control; + public int Control; /// Is the Shift modifier pressed? - public bool Shift; + public int Shift; } //////////////////////////////////////////////////////////// diff --git a/dotnet/src/Window/EventArgs.cs b/dotnet/src/Window/EventArgs.cs index 89c47744f..d66e569c1 100644 --- a/dotnet/src/Window/EventArgs.cs +++ b/dotnet/src/Window/EventArgs.cs @@ -20,9 +20,9 @@ namespace SFML public KeyEventArgs(KeyEvent e) { Code = e.Code; - Alt = e.Alt; - Control = e.Control; - Shift = e.Shift; + Alt = e.Alt != 0; + Control = e.Control != 0; + Shift = e.Shift != 0; } /// Code of the key (see KeyCode enum) diff --git a/dotnet/src/Window/Window.cs b/dotnet/src/Window/Window.cs index 51041e9b6..eb1df9bab 100644 --- a/dotnet/src/Window/Window.cs +++ b/dotnet/src/Window/Window.cs @@ -47,7 +47,7 @@ namespace SFML /// Title of the window //////////////////////////////////////////////////////////// public Window(VideoMode mode, string title) : - this(mode, title, Styles.Resize | Styles.Close, new WindowSettings(24, 8, 0)) + this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8, 0)) { } @@ -60,7 +60,7 @@ namespace SFML /// Window style (Resize | Close by default) //////////////////////////////////////////////////////////// public Window(VideoMode mode, string title, Styles style) : - this(mode, title, style, new WindowSettings(24, 8, 0)) + this(mode, title, style, new ContextSettings(24, 8, 0)) { } @@ -73,7 +73,7 @@ namespace SFML /// Window style (Resize | Close by default) /// Creation parameters //////////////////////////////////////////////////////////// - public Window(VideoMode mode, string title, Styles style, WindowSettings settings) : + public Window(VideoMode mode, string title, Styles style, ContextSettings settings) : base(sfWindow_Create(mode, title, style, settings)) { myInput = new Input(sfWindow_GetInput(This)); @@ -86,7 +86,7 @@ namespace SFML /// Platform-specific handle of the control //////////////////////////////////////////////////////////// public Window(IntPtr handle) : - this(handle, new WindowSettings(24, 8, 0)) + this(handle, new ContextSettings(24, 8, 0)) { } @@ -97,31 +97,12 @@ namespace SFML /// Platform-specific handle of the control /// Creation parameters //////////////////////////////////////////////////////////// - public Window(IntPtr Handle, WindowSettings settings) : + public Window(IntPtr Handle, ContextSettings settings) : base(sfWindow_CreateFromHandle(Handle, settings)) { myInput = new Input(sfWindow_GetInput(This)); } - //////////////////////////////////////////////////////////// - /// - /// Return the list of window's events which happened since last call - /// - /// Array of events - //////////////////////////////////////////////////////////// - public Event[] Events - { - get - { - Event Evt; - List Evts = new List(); - while (GetEvent(out Evt)) - Evts.Add(Evt); - - return Evts.ToArray(); - } - } - //////////////////////////////////////////////////////////// /// /// Input manager of the window @@ -192,7 +173,7 @@ namespace SFML /// Creation settings of the window /// //////////////////////////////////////////////////////////// - public virtual WindowSettings Settings + public virtual ContextSettings Settings { get { return sfWindow_GetSettings(This); } } @@ -360,12 +341,12 @@ namespace SFML //////////////////////////////////////////////////////////// /// /// Call the event handlers for each pending event. - /// Use of this function is exclusive with the Events property (use one or the other) /// //////////////////////////////////////////////////////////// public void DispatchEvents() { - foreach (Event e in Events) + Event e; + while (GetEvent(out e)) { switch (e.Type) { @@ -540,10 +521,10 @@ namespace SFML #region Imports [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] - static extern IntPtr sfWindow_Create(VideoMode Mode, string Title, Styles Style, WindowSettings Params); + static extern IntPtr sfWindow_Create(VideoMode Mode, string Title, Styles Style, ContextSettings Params); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] - static extern IntPtr sfWindow_CreateFromHandle(IntPtr Handle, WindowSettings Params); + static extern IntPtr sfWindow_CreateFromHandle(IntPtr Handle, ContextSettings Params); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] static extern void sfWindow_Destroy(IntPtr This); @@ -570,7 +551,7 @@ namespace SFML static extern uint sfWindow_GetHeight(IntPtr This); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] - static extern WindowSettings sfWindow_GetSettings(IntPtr This); + static extern ContextSettings sfWindow_GetSettings(IntPtr This); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] static extern void sfWindow_UseVerticalSync(IntPtr This, bool Enable); diff --git a/dotnet/src/Window/sfml-window.csproj b/dotnet/src/Window/sfml-window.csproj index 33c095f90..3449efc32 100644 --- a/dotnet/src/Window/sfml-window.csproj +++ b/dotnet/src/Window/sfml-window.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 8.0.50727 + 9.0.21022 2.0 {D17DE83D-A592-461F-8AF2-53F9E22E1D0F} Library @@ -48,6 +48,7 @@ --> + @@ -55,7 +56,6 @@ -