agate-svn-commit Mailing List for AgateLib (Page 5)
Status: Alpha
Brought to you by:
kanato
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
(86) |
May
(77) |
Jun
|
Jul
(1) |
Aug
(31) |
Sep
(12) |
Oct
(31) |
Nov
(53) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(53) |
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
(7) |
Dec
(13) |
2011 |
Jan
(17) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
(21) |
Dec
|
2012 |
Jan
(6) |
Feb
(14) |
Mar
(5) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(8) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(5) |
Nov
(9) |
Dec
(5) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
|
Jun
(5) |
Jul
(33) |
Aug
(69) |
Sep
(35) |
Oct
(4) |
Nov
(1) |
Dec
|
From: <ka...@us...> - 2014-08-04 05:58:52
|
Revision: 1437 http://sourceforge.net/p/agate/code/1437 Author: kanato Date: 2014-08-04 05:58:46 +0000 (Mon, 04 Aug 2014) Log Message: ----------- Some modifications to file provider. Modified Paths: -------------- trunk/AgateLib/IO/FileProvider.cs trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs Modified: trunk/AgateLib/IO/FileProvider.cs =================================================================== --- trunk/AgateLib/IO/FileProvider.cs 2014-08-04 05:33:00 UTC (rev 1436) +++ trunk/AgateLib/IO/FileProvider.cs 2014-08-04 05:58:46 UTC (rev 1437) @@ -22,22 +22,22 @@ public static IReadFileProvider SurfaceAssets { get { return mSurfaceAssets ?? Assets; } - set { mSurfaceAssets = Assets; } + set { mSurfaceAssets = value; } } public static IReadFileProvider ResourceAssets { get { return mResourceAssets ?? Assets; } - set { mResourceAssets = Assets; } + set { mResourceAssets = value; } } public static IReadFileProvider MusicAssets { get { return mMusicAssets ?? Assets; } - set { mMusicAssets = Assets; } + set { mMusicAssets = value; } } public static IReadFileProvider SoundAssets { get { return mSoundAssets ?? Assets; } - set { mSoundAssets = Assets; } + set { mSoundAssets = value; } } public static IReadWriteFileProvider UserFiles { get; private set; } Modified: trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs =================================================================== --- trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs 2014-08-04 05:33:00 UTC (rev 1436) +++ trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs 2014-08-04 05:58:46 UTC (rev 1437) @@ -33,6 +33,7 @@ SDL_Audio audio; IntPtr music; string tempfile; + string filename; double mVolume; public SDL_Music(SDL_Audio audio, Stream stream) @@ -52,8 +53,8 @@ sdl = SdlFactory.CreateSDL(); this.audio = audio; - - LoadFromFile(filename); + this.filename = AgateLib.IO.FileProvider.MusicAssets.ResolveFile(filename); + LoadFromFile(this.filename); } ~SDL_Music() Modified: trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs 2014-08-04 05:33:00 UTC (rev 1436) +++ trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs 2014-08-04 05:58:46 UTC (rev 1437) @@ -45,7 +45,8 @@ public IReadFileProvider CreateAssetFileProvider() { - return new FileSystemProvider(AssemblyLoadDirectory); + //return new FileSystemProvider(AssemblyLoadDirectory); + return new FileSystemProvider("."); } static public string AssemblyLoadDirectory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-08-04 05:33:07
|
Revision: 1436 http://sourceforge.net/p/agate/code/1436 Author: kanato Date: 2014-08-04 05:33:00 +0000 (Mon, 04 Aug 2014) Log Message: ----------- Add subdirectory provider. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/IO/FileProvider.cs trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs trunk/AgateLib.GL/AgateLib.GL.csproj trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj Added Paths: ----------- trunk/AgateLib/IO/SubDirectoryProvider.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-08-04 05:09:51 UTC (rev 1435) +++ trunk/AgateLib/AgateLib.csproj 2014-08-04 05:33:00 UTC (rev 1436) @@ -52,6 +52,24 @@ <ErrorReport>prompt</ErrorReport> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> <ItemGroup> <!-- A reference to the entire .NET Framework is automatically included --> </ItemGroup> @@ -132,6 +150,7 @@ <Compile Include="IO\IPath.cs" /> <Compile Include="IO\IReadWriteFileProvider.cs" /> <Compile Include="IO\IWriteFileProvider.cs" /> + <Compile Include="IO\SubDirectoryProvider.cs" /> <Compile Include="Platform\IStopWatch.cs" /> <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> Modified: trunk/AgateLib/IO/FileProvider.cs =================================================================== --- trunk/AgateLib/IO/FileProvider.cs 2014-08-04 05:09:51 UTC (rev 1435) +++ trunk/AgateLib/IO/FileProvider.cs 2014-08-04 05:33:00 UTC (rev 1436) @@ -42,5 +42,9 @@ public static IReadWriteFileProvider UserFiles { get; private set; } + public static IReadFileProvider NewProviderFromSubdirectory(IReadFileProvider parent, string subdir) + { + return new SubdirectoryProvider(parent, subdir); + } } } Added: trunk/AgateLib/IO/SubDirectoryProvider.cs =================================================================== --- trunk/AgateLib/IO/SubDirectoryProvider.cs (rev 0) +++ trunk/AgateLib/IO/SubDirectoryProvider.cs 2014-08-04 05:33:00 UTC (rev 1436) @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public class SubdirectoryProvider : IReadFileProvider + { + private IReadFileProvider parent; + private string subdir; + + public SubdirectoryProvider(IReadFileProvider parent, string subdir) + { + // TODO: Complete member initialization + this.parent = parent; + this.subdir = subdir.Replace('\\', '/'); + + if (this.subdir.EndsWith("/") == false) + this.subdir += "/"; + } + + public System.IO.Stream OpenRead(string filename) + { + return parent.OpenRead(subdir + filename); + } + + public bool FileExists(string filename) + { + return parent.FileExists(subdir + filename); + } + + public IEnumerable<string> GetAllFiles() + { + return parent.GetAllFiles(subdir + "**"); + } + + public IEnumerable<string> GetAllFiles(string searchPattern) + { + return parent.GetAllFiles(subdir + searchPattern); + } + + public string ReadAllText(string filename) + { + return parent.ReadAllText(subdir + filename); + } + + public bool IsRealFile(string filename) + { + return parent.IsRealFile(subdir + filename); + } + + public string ResolveFile(string filename) + { + return parent.ResolveFile(subdir + filename); + } + } +} Modified: trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj =================================================================== --- trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj 2014-08-04 05:09:51 UTC (rev 1435) +++ trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj 2014-08-04 05:33:00 UTC (rev 1436) @@ -31,6 +31,46 @@ <WarningLevel>4</WarningLevel> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> Modified: trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs =================================================================== --- trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs 2014-08-04 05:09:51 UTC (rev 1435) +++ trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs 2014-08-04 05:33:00 UTC (rev 1436) @@ -51,7 +51,7 @@ { sdl = SdlFactory.CreateSDL(); - this.filename = filename; + this.filename = AgateLib.IO.FileProvider.SoundAssets.ResolveFile(filename); LoadFromFile(filename); } Modified: trunk/AgateLib.GL/AgateLib.GL.csproj =================================================================== --- trunk/AgateLib.GL/AgateLib.GL.csproj 2014-08-04 05:09:51 UTC (rev 1435) +++ trunk/AgateLib.GL/AgateLib.GL.csproj 2014-08-04 05:33:00 UTC (rev 1436) @@ -52,6 +52,26 @@ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> <ItemGroup> <Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-08-04 05:09:51 UTC (rev 1435) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-08-04 05:33:00 UTC (rev 1436) @@ -52,6 +52,26 @@ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> <ItemGroup> <Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-08-04 05:09:55
|
Revision: 1435 http://sourceforge.net/p/agate/code/1435 Author: kanato Date: 2014-08-04 05:09:51 +0000 (Mon, 04 Aug 2014) Log Message: ----------- Fix AgateSDL for 32 bit SDL. Modified Paths: -------------- trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2.cs trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2_image.cs trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2_mixer.cs trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2_ttf.cs trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2.cs trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2_image.cs trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2_mixer.cs trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2_ttf.cs Modified: trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2.cs =================================================================== --- trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2.cs 2014-08-03 17:32:32 UTC (rev 1434) +++ trunk/AgateLib.AgateSDL/Sdl2/SixtyFour/SDL2.cs 2014-08-04 05:09:51 UTC (rev 1435) @@ -1,5620 +1,5620 @@ -#region License -/* SDL2# - C# Wrapper for SDL2 - * - * Copyright (c) 2013-2014 Ethan Lee. - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in a - * product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source distribution. - * - * Ethan "flibitijibibo" Lee <fli...@fl...> - * - */ -#endregion - -#region Using Statements -using System; -using System.Runtime.InteropServices; +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2014 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee <fli...@fl...> + * + */ #endregion -namespace SDL2.SixtyFour -{ - /// <summary> - /// Entry point for all SDL-related (non-extension) types and methods - /// </summary> - public static class SDL - { - #region SDL2# Variables - - /// <summary> - /// Used by DllImport to load the native library. - /// </summary> - private const string nativeLibName = "lib64/SDL2.dll"; - - #endregion - - #region SDL_stdinc.h - - public static uint SDL_FOURCC(byte A, byte B, byte C, byte D) - { - return (uint) (A | (B << 8) | (C << 16) | (D << 24)); - } - - public enum SDL_bool - { - SDL_FALSE = 0, - SDL_TRUE = 1 - } - - #endregion - - #region SDL_rwops.h - - /* Note about SDL2# and Internal RWops: - * These functions are currently not supported for public use. - * They are only meant to be used internally in functions marked with - * the phrase "THIS IS AN RWops FUNCTION!" - */ - - /// <summary> - /// Use this function to create a new SDL_RWops structure for reading from and/or writing to a named file. - /// </summary> - /// <param name="file">a UTF-8 string representing the filename to open</param> - /// <param name="mode">an ASCII string representing the mode to be used for opening the file; see Remarks for details</param> - /// <returns>Returns a pointer to the SDL_RWops structure that is created, or NULL on failure; call SDL_GetError() for more information.</returns> - [DllImport(nativeLibName, EntryPoint = "SDL_RWFromFile", CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr INTERNAL_SDL_RWFromFile( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string file, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string mode - ); - - /* These are the public RWops functions. They should be used by - * functions marked with the phrase "THIS IS A PUBLIC RWops FUNCTION!" - */ - - /* IntPtr refers to an SDL_RWops */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_RWFromMem(byte[] mem, int size); - - #endregion - - #region SDL_main.h - - /// <summary> - /// Use this function to circumvent failure of SDL_Init() when not using SDL_main() as an entry point. - /// </summary> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_SetMainReady(); - - #endregion - - #region SDL.h - - public const uint SDL_INIT_TIMER = 0x00000001; - public const uint SDL_INIT_AUDIO = 0x00000010; - public const uint SDL_INIT_VIDEO = 0x00000020; - public const uint SDL_INIT_JOYSTICK = 0x00000200; - public const uint SDL_INIT_HAPTIC = 0x00001000; - public const uint SDL_INIT_GAMECONTROLLER = 0x00002000; - public const uint SDL_INIT_NOPARACHUTE = 0x00100000; - public const uint SDL_INIT_EVERYTHING = ( - SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | - SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | - SDL_INIT_GAMECONTROLLER - ); - - /// <summary> - /// Use this function to initialize the SDL library. - /// This must be called before using any other SDL function. - /// </summary> - /// <param name="flags">subsystem initialization flags; see Remarks for details</param> - /// <returns>Returns 0 on success or a negative error code on failure. - /// Call <see cref="SDL_GetError()"/> for more information.</returns> - /// <remarks>The Event Handling, File I/O, and Threading subsystems are initialized by default. - /// You must specifically initialize other subsystems if you use them in your application.</remarks> - /// <remarks>Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup signal handlers - /// for some commonly ignored fatal signals (like SIGSEGV). </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_Init(uint flags); - - /// <summary> - /// Use this function to initialize specific SDL subsystems. - /// </summary> - /// <param name="flags">any of the flags used by SDL_Init(); see Remarks for details</param> - /// <returns>Returns 0 on success or a negative error code on failure. - /// Call <see cref="SDL_GetError()"/> for more information.</returns> - /// <remarks>After SDL has been initialized with <see cref="SDL_Init()"/> you may initialize - /// uninitialized subsystems with <see cref="SDL_InitSubSystem()"/>.</remarks> - /// <remarks>If you want to initialize subsystems separately you would call <see cref="SDL_Init(0)"/> - /// followed by <see cref="SDL_InitSubSystem()"/> with the desired subsystem flag. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_InitSubSystem(uint flags); - - /// <summary> - /// Use this function to clean up all initialized subsystems. - /// You should call it upon all exit conditions. - /// </summary> - /// <remarks>You should call this function even if you have already shutdown each initialized - /// subsystem with <see cref="SDL_QuitSubSystem()"/>.</remarks> - /// <remarks>If you start a subsystem using a call to that subsystem's init function (for example - /// <see cref="SDL_VideoInit()"/>) instead of <see cref="SDL_Init()"/> or <see cref="SDL_InitSubSystem()"/>, - /// then you must use that subsystem's quit function (<see cref="SDL_VideoQuit()"/>) to shut it down - /// before calling <see cref="SDL_Quit()"/>.</remarks> - /// <remarks>You can use this function with atexit() to ensure that it is run when your application is - /// shutdown, but it is not wise to do this from a library or other dynamically loaded code. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_Quit(); - - /// <summary> - /// Use this function to shut down specific SDL subsystems. - /// </summary> - /// <param name="flags">any of the flags used by <see cref="SDL_Init()"/>; see Remarks for details</param> - /// <remarks>If you start a subsystem using a call to that subsystem's init function (for example - /// <see cref="SDL_VideoInit()"/>) instead of <see cref="SDL_Init()"/> or <see cref="SDL_InitSubSystem()"/>, - /// then you must use that subsystem's quit function (<see cref="SDL_VideoQuit()"/>) to shut it down - /// before calling <see cref="SDL_Quit()"/>.</remarks> - /// <remarks>You can use this function with atexit() to en - /// <remarks>You still need to call <see cref="SDL_Quit()"/> even if you close all open subsystems with SDL_QuitSubSystem(). </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_QuitSubSystem(uint flags); - - /// <summary> - /// Use this function to return a mask of the specified subsystems which have previously been initialized. - /// </summary> - /// <param name="flags">any of the flags used by <see cref="SDL_Init()"/>; see Remarks for details</param> - /// <returns>If flags is 0 it returns a mask of all initialized subsystems, otherwise it returns the - /// initialization status of the specified subsystems. The return value does not include SDL_INIT_NOPARACHUTE.</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint SDL_WasInit(uint flags); - - #endregion - - #region SDL_platform.h - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetPlatform(); - - #endregion - - #region SDL_hints.h - - public const string SDL_HINT_FRAMEBUFFER_ACCELERATION = - "SDL_FRAMEBUFFER_ACCELERATION"; - public const string SDL_HINT_RENDER_DRIVER = - "SDL_RENDER_DRIVER"; - public const string SDL_HINT_RENDER_OPENGL_SHADERS = - "SDL_RENDER_OPENGL_SHADERS"; - public const string SDL_HINT_RENDER_DIRECT3D_THREADSAFE = - "SDL_RENDER_DIRECT3D_THREADSAFE"; - public const string SDL_HINT_RENDER_VSYNC = - "SDL_RENDER_VSYNC"; - public const string SDL_HINT_VIDEO_X11_XVIDMODE = - "SDL_VIDEO_X11_XVIDMODE"; - public const string SDL_HINT_VIDEO_X11_XINERAMA = - "SDL_VIDEO_X11_XINERAMA"; - public const string SDL_HINT_VIDEO_X11_XRANDR = - "SDL_VIDEO_X11_XRANDR"; - public const string SDL_HINT_GRAB_KEYBOARD = - "SDL_GRAB_KEYBOARD"; - public const string SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS = - "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"; - public const string SDL_HINT_IDLE_TIMER_DISABLED = - "SDL_IOS_IDLE_TIMER_DISABLED"; - public const string SDL_HINT_ORIENTATIONS = - "SDL_IOS_ORIENTATIONS"; - public const string SDL_HINT_XINPUT_ENABLED = - "SDL_XINPUT_ENABLED"; - public const string SDL_HINT_GAMECONTROLLERCONFIG = - "SDL_GAMECONTROLLERCONFIG"; - public const string SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS = - "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"; - public const string SDL_HINT_ALLOW_TOPMOST = - "SDL_ALLOW_TOPMOST"; - public const string SDL_HINT_TIMER_RESOLUTION = - "SDL_TIMER_RESOLUTION"; - public const string SDL_HINT_RENDER_SCALE_QUALITY = - "SDL_RENDER_SCALE_QUALITY"; - - /* Only available in SDL 2.0.1 or higher */ - public const string SDL_HINT_VIDEO_HIGHDPI_DISABLED = - "SDL_VIDEO_HIGHDPI_DISABLED"; - - /* Only available in SDL 2.0.2 or higher */ - public const string SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK = - "SDL_CTRL_CLICK_EMULATE_RIGHT_CLICK"; - public const string SDL_HINT_VIDEO_WIN_D3DCOMPILER = - "SDL_VIDEO_WIN_D3DCOMPILER"; - public const string SDL_HINT_MOUSE_RELATIVE_MODE_WARP = - "SDL_MOUSE_RELATIVE_MODE_WARP"; - public const string SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT = - "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"; - public const string SDL_HINT_VIDEO_ALLOW_SCREENSAVER = - "SDL_VIDEO_ALLOW_SCREENSAVER"; - public const string SDL_HINT_ACCELEROMETER_AS_JOYSTICK = - "SDL_ACCELEROMETER_AS_JOYSTICK"; - public const string SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES = - "SDL_VIDEO_MAC_FULLSCREEN_SPACES"; - - public enum SDL_HintPriority - { - SDL_HINT_DEFAULT, - SDL_HINT_NORMAL, - SDL_HINT_OVERRIDE - } - - /// <summary> - /// Use this function to clear all hints. - /// </summary> - /// <remarks>This function is automatically called during <see cref="SDL_Quit()"/>. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_ClearHints(); - - /// <summary> - /// Use this function to get the value of a hint. - /// </summary> - /// <param name="name">the hint to query; see the list of hints on - /// <a href="http://wiki.libsdl.org/moin.cgi/CategoryHints#Hints">CategoryHints</a> for details</param> - /// <returns>Returns the string value of a hint or NULL if the hint isn't set.</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetHint( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name - ); - - /// <summary> - /// Use this function to set a hint with normal priority. - /// </summary> - /// <param name="name">the hint to query; see the list of hints on - /// <a href="http://wiki.libsdl.org/moin.cgi/CategoryHints#Hints">CategoryHints</a> for details</param> - /// <param name="value">the value of the hint variable</param> - /// <returns>Returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.</returns> - /// <remarks>Hints will not be set if there is an existing override hint or environment - /// variable that takes precedence. You can use <see cref="SDL_SetHintWithPriority()"/> to set the hint with - /// override priority instead.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_bool SDL_SetHint( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string value - ); - - /// <summary> - /// Use this function to set a hint with a specific priority. - /// </summary> - /// <param name="name">the hint to query; see the list of hints on - /// <a href="http://wiki.libsdl.org/moin.cgi/CategoryHints#Hints">CategoryHints</a> for details</param> - /// <param name="value">the value of the hint variable</param> - /// <param name="priority">the <see cref="SDL_HintPriority"/> level for the hint</param> - /// <returns>Returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.</returns> - /// <remarks>The priority controls the behavior when setting a hint that already has a value. - /// Hints will replace existing hints of their priority and lower. Environment variables are - /// considered to have override priority. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_bool SDL_SetHintWithPriority( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string value, - SDL_HintPriority priority - ); - - #endregion - - #region SDL_error.h - - /// <summary> - /// Use this function to clear any previous error message. - /// </summary> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_ClearError(); - - /// <summary> - /// Use this function to retrieve a message about the last error that occurred. - /// </summary> - /// <returns>Returns a message with information about the specific error that occurred, - /// or an empty string if there hasn't been an error since the last call to <see cref="SDL_ClearError()"/>. - /// Without calling <see cref="SDL_ClearError()"/>, the message is only applicable when an SDL function - /// has signaled an error. You must check the return values of SDL function calls to determine - /// when to appropriately call <see cref="SDL_GetError()"/>. - /// This string is statically allocated and must not be freed by the application.</returns> - /// <remarks>It is possible for multiple errors to occur before calling SDL_GetError(). Only the last error is returned. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetError(); - - /// <summary> - /// Use this function to set the SDL error string. - /// </summary> - /// <param name="fmt">a printf() style message format string </param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>Calling this function will replace any previous error message that was set.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_SetError( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - #endregion - - #region SDL_log.h - - /* Begin nameless enum SDL_LOG_CATEGORY */ - public const int SDL_LOG_CATEGORY_APPLICATION = 0; - public const int SDL_LOG_CATEGORY_ERROR = 1; - public const int SDL_LOG_CATEGORY_ASSERT = 2; - public const int SDL_LOG_CATEGORY_SYSTEM = 3; - public const int SDL_LOG_CATEGORY_AUDIO = 4; - public const int SDL_LOG_CATEGORY_VIDEO = 5; - public const int SDL_LOG_CATEGORY_RENDER = 6; - public const int SDL_LOG_CATEGORY_INPUT = 7; - public const int SDL_LOG_CATEGORY_TEST = 8; - - /* Reserved for future SDL library use */ - public const int SDL_LOG_CATEGORY_RESERVED1 = 9; - public const int SDL_LOG_CATEGORY_RESERVED2 = 10; - public const int SDL_LOG_CATEGORY_RESERVED3 = 11; - public const int SDL_LOG_CATEGORY_RESERVED4 = 12; - public const int SDL_LOG_CATEGORY_RESERVED5 = 13; - public const int SDL_LOG_CATEGORY_RESERVED6 = 14; - public const int SDL_LOG_CATEGORY_RESERVED7 = 15; - public const int SDL_LOG_CATEGORY_RESERVED8 = 16; - public const int SDL_LOG_CATEGORY_RESERVED9 = 17; - public const int SDL_LOG_CATEGORY_RESERVED10 = 18; - - /* Beyond this point is reserved for application use, e.g. - enum { - LOG_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, - LOG_CATEGORY_AWESOME2, - LOG_CATEGORY_AWESOME3, - ... - }; - */ - public const int SDL_LOG_CATEGORY_CUSTOM = 19; - /* End nameless enum SDL_LOG_CATEGORY */ - - /// <summary> - /// An enumeration of the predefined log priorities. - /// </summary> - public enum SDL_LogPriority - { - SDL_LOG_PRIORITY_VERBOSE = 1, - SDL_LOG_PRIORITY_DEBUG, - SDL_LOG_PRIORITY_INFO, - SDL_LOG_PRIORITY_WARN, - SDL_LOG_PRIORITY_ERROR, - SDL_LOG_PRIORITY_CRITICAL, - SDL_NUM_LOG_PRIORITIES - } - - /// <summary> - /// Used as a callback for <see cref="SDL_LogGetOutputFunction()"/> and <see cref="SDL_LogSetOutputFunction()"/> - /// </summary> - /// <param name="userdata">what was passed as userdata to <see cref="SDL_LogSetOutputFunction()"/></param> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="priority">the priority of the message; see Remarks for details</param> - /// <param name="message">the message being output</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void SDL_LogOutputFunction( - IntPtr userdata, // void* - int category, - SDL_LogPriority priority, - IntPtr message // const char* - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO. - /// </summary> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_Log( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_VERBOSE. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogVerbose( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_DEBUG. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogDebug( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_INFO. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogInfo( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_WARN. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogWarn( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_ERROR. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogError( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_CRITICAL. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogCritical( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with the specified category and priority. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="priority">the priority of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogMessage( - int category, - SDL_LogPriority priority, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with the specified category and priority. - /// This version of <see cref="SDL_LogMessage"/> uses a stdarg variadic argument list. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="priority">the priority of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogMessageV( - int category, - SDL_LogPriority priority, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to get the priority of a particular log category. - /// </summary> - /// <param name="category">the category to query; see Remarks for details</param> - /// <returns>Returns the <see cref="SDL_LogPriority"/> for the requested category; see Remarks for details. </returns> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The returned priority will be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_LogPriority SDL_LogGetPriority( - int category - ); - - /// <summary> - /// Use this function to set the priority of a particular log category. - /// </summary> - /// <param name="category">the category to query; see Remarks for details</param> - /// <param name="priority">the <see cref="SDL_LogPriority"/> of the message; see Remarks for details</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogSetPriority( - int category, - SDL_LogPriority priority - ); - - /// <summary> - /// Use this function to set the priority of all log categories. - /// </summary> - /// <param name="priority">the <see cref="SDL_LogPriority"/> of the message; see Remarks for details</param> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogSetAllPriority( - SDL_LogPriority priority - ); - - /// <summary> - /// Use this function to reset all priorities to default. - /// </summary> - /// <remarks>This is called in <see cref="SDL_Quit()"/>. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogResetPriorities(); - - /// <summary> - /// Use this function to get the current log output function. - /// </summary> - /// <param name="callback">a pointer filled in with the current log callback; see Remarks for details</param> - /// <param name="userdata">a pointer filled in with the pointer that is passed to callback (refers to void*)</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogGetOutputFunction( - out SDL_LogOutputFunction callback, - out IntPtr userdata - ); - - /* userdata refers to a void* */ - /// <summary> - /// Use this function to replace the default log output function with one of your own. - /// </summary> - /// <param name="callback">the function to call instead of the default; see Remarks for details</param> - /// <param name="userdata">a pointer that is passed to callback (refers to void*)</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogSetOutputFunction( - SDL_LogOutputFunction callback, - IntPtr userdata - ); - - #endregion - - #region SDL_messagebox.h - - [Flags] - public enum SDL_MessageBoxFlags : uint - { - SDL_MESSAGEBOX_ERROR = 0x00000010, - SDL_MESSAGEBOX_WARNING = 0x00000020, - SDL_MESSAGEBOX_INFORMATION = 0x00000040 - } - - [Flags] - public enum SDL_MessageBoxButtonFlags : uint - { - SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, - SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 - } - - [StructLayout(LayoutKind.Sequential)] - private struct INTERNAL_SDL_MessageBoxButtonData - { - public SDL_MessageBoxButtonFlags flags; - public int buttonid; - public IntPtr text; /* The UTF-8 button text */ - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxButtonData - { - public SDL_MessageBoxButtonFlags flags; - public int buttonid; - public string text; /* The UTF-8 button text */ - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxColor - { - public byte r, g, b; - } - - public enum SDL_MessageBoxColorType - { - SDL_MESSAGEBOX_COLOR_BACKGROUND, - SDL_MESSAGEBOX_COLOR_TEXT, - SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, - SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, - SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, - SDL_MESSAGEBOX_COLOR_MAX - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxColorScheme - { - [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)SDL_MessageBoxColorType.SDL_MESSAGEBOX_COLOR_MAX)] - public SDL_MessageBoxColor[] colors; - } - - [StructLayout(LayoutKind.Sequential)] - private struct INTERNAL_SDL_MessageBoxData - { - public SDL_MessageBoxFlags flags; - public IntPtr window; /* Parent window, can be NULL */ - public IntPtr title; /* UTF-8 title */ - public IntPtr message; /* UTF-8 message text */ - public int numbuttons; - public IntPtr buttons; - public IntPtr colorScheme; /* Can be NULL to use system settings */ - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxData - { - public SDL_MessageBoxFlags flags; - public IntPtr window; /* Parent window, can be NULL */ - public string title; /* UTF-8 title */ - public string message; /* UTF-8 message text */ - public int numbuttons; - public SDL_MessageBoxButtonData[] buttons; - public SDL_MessageBoxColorScheme? colorScheme; /* Can be NULL to use system settings */ - } - - /// <summary> - /// - /// </summary> - /// <param name="messageboxdata"></param> - /// <param name="buttonid"></param> - /// <returns></returns> - [DllImport(nativeLibName, EntryPoint = "SDL_ShowMessageBox", CallingConvention = CallingConvention.Cdecl)] - private static extern int INTERNAL_SDL_ShowMessageBox([In()] ref INTERNAL_SDL_MessageBoxData messageboxdata, out int buttonid); - - /// <summary> - /// - /// </summary> - /// <param name="messageboxdata"></param> - /// <param name="buttonid"></param> - /// <returns></returns> - public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid) - { - var utf8 = LPUtf8StrMarshaler.GetInstance(null); - - var data = new INTERNAL_SDL_MessageBoxData() - { - flags = messageboxdata.flags, - window = messageboxdata.window, - title = utf8.MarshalManagedToNative(messageboxdata.title), - message = utf8.MarshalManagedToNative(messageboxdata.message), - numbuttons = messageboxdata.numbuttons, - }; - - var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons]; - for (int i = 0; i < messageboxdata.numbuttons; i++) - { - buttons[i] = new INTERNAL_SDL_MessageBoxButtonData() - { - flags = messageboxdata.buttons[i].flags, - buttonid = messageboxdata.buttons[i].buttonid, - text = utf8.MarshalManagedToNative(messageboxdata.buttons[i].text), - }; - } - - if (messageboxdata.colorScheme != null) - { - data.colorScheme = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDL_MessageBoxColorScheme))); - Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false); - } - - int result; - fixed (INTERNAL_SDL_MessageBoxButtonData* buttonsPtr = &buttons[0]) - { - data.buttons = (IntPtr)buttonsPtr; - result = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid); - } - - Marshal.FreeHGlobal(data.colorScheme); - for (int i = 0; i < messageboxdata.numbuttons; i++) - { - utf8.CleanUpNativeData(buttons[i].text); - } - utf8.CleanUpNativeData(data.message); - utf8.CleanUpNativeData(data.title); - - return result; - } - - /// <summary> - /// Use this function to display a simple message box. - /// </summary> - /// <param name="flags">An <see cref="SDL_MessageBoxFlag"/>; see Remarks for details;</param> - /// <param name="title">UTF-8 title text</param> - /// <param name="message">UTF-8 message text</param> - /// <param name="window">the parent window, or NULL for no parent (refers to a <see cref="SDL_Window"/></param> - /// <returns>0 on success or a negative error code on failure; call SDL_GetError() for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_ShowSimpleMessageBox( - SDL_MessageBoxFlags flags, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string title, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string message, - IntPtr window - ); - - #endregion - - #region SDL_version.h, SDL_revision.h - - /* Similar to the headers, this is the version we're expecting to be - * running with. You will likely want to check this somewhere in your - * program! - */ - public const int SDL_MAJOR_VERSION = 2; - public const int SDL_MINOR_VERSION = 0; - public const int SDL_PATCHLEVEL = 3; - - public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM( - SDL_MAJOR_VERSION, - SDL_MINOR_VERSION, - SDL_PATCHLEVEL - ); - - /// <summary> - /// A structure that contains information about the version of SDL in use. - /// </summary> - /// <remarks>Represents the library's version as three levels: </remarks> - /// <remarks>major revision (increments with massive changes, additions, and enhancements) </remarks> - /// <remarks>minor revision (increments with backwards-compatible changes to the major revision), and </remarks> - /// <remarks>patchlevel (increments with fixes to the minor revision)</remarks> - /// <remarks><see cref="SDL_VERSION"/> can be used to populate this structure with information</remarks> - [StructLayout(LayoutKind.Sequential)] - public struct SDL_version - { - public byte major; - public byte minor; - public byte patch; - } - - /// <summary> - /// Use this macro to determine the SDL version your program was compiled against. - /// </summary> - /// <param name="x">an <see cref="SDL_version"/> structure to initialize</param> - public static void SDL_VERSION(out SDL_version x) - { - x.major = SDL_MAJOR_VERSION; - x.minor = SDL_MINOR_VERSION; - x.patch = SDL_PATCHLEVEL; - } - - /// <summary> - /// Use this macro to convert separate version components into a single numeric value. - /// </summary> - /// <param name="X">major version; reported in thousands place</param> - /// <param name="Y">minor version; reported in hundreds place</param> - /// <param name="Z">update version (patchlevel); reported in tens and ones places</param> - /// <returns></returns> - /// <remarks>This assumes that there will never be more than 100 patchlevels.</remarks> - /// <remarks>Example: SDL_VERSIONNUM(1,2,3) -> (1203)</remarks> - public static int SDL_VERSIONNUM(int X, int Y, int Z) - { - return (X * 1000) + (Y * 100) + Z; - } - - /// <summary> - /// Use this macro to determine whether the SDL version compiled against is at least as new as the specified version. - /// </summary> - /// <param name="X">major version</param> - /// <param name="Y">minor version</param> - /// <param name="Z">update version (patchlevel)</param> - /// <returns>This macro will evaluate to true if compiled with SDL version at least X.Y.Z. </returns> - public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z) - { - return (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)); - } - - /// <summary> - /// Use this function to get the version of SDL that is linked against your program. - /// </summary> - /// <param name="ver">the <see cref="SDL_version"/> structure that contains the version information</param> - /// <remarks>This function may be called safely at any time, even before SDL_Init(). </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - private static extern void SDL_GetVersion(out SDL_version ver); - - /// <summary> - /// Use this function to get the code revision of SDL that is linked against your program. - /// </summary> - /// <returns>Returns an arbitrary string, uniquely identifying the exact revision - /// of the SDL library in use. </returns> - /// <remarks>The revision is a string including sequential revision number that is - /// incremented with each commit, and a hash of the last code change.</remarks> - /// <remarks>Example: hg-5344:94189aa89b54</remarks> - /// <remarks>This value is the revision of the code you are linked with and may be - /// different from the code you are compiling with, which is found in the constant SDL_REVISION.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetRevision(); - - /// <summary> - /// Use this function to get the revision number of SDL that is linked against your program. - /// </summary> - /// <returns>Returns a number uniquely identifying the exact revision of the SDL library in use.</returns> - /// <remarks>This is an incrementing number based on commits to hg.libsdl.org.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetRevisionNumber(); - - #endregion - - #region SDL_video.h - - /* Actually, this is from SDL_blendmode.h */ - /// <summary> - /// An enumeration of blend modes used in SDL_RenderCopy() and drawing operations. - /// </summary> - [Flags] - public enum SDL_BlendMode - { - SDL_BLENDMODE_NONE = 0x00000000, - SDL_BLENDMODE_BLEND = 0x00000001, - SDL_BLENDMODE_ADD = 0x00000002, - SDL_BLENDMODE_MOD = 0x00000004 - } - - /// <summary> - /// An enumeration of OpenGL configuration attributes. - /// </summary> - public enum SDL_GLattr - { - SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, - SDL_GL_RETAINED_BACKING, - SDL_GL_CONTEXT_MAJOR_VERSION, - SDL_GL_CONTEXT_MINOR_VERSION, - SDL_GL_CONTEXT_EGL, - SDL_GL_CONTEXT_FLAGS, - SDL_GL_CONTEXT_PROFILE_MASK, - SDL_GL_SHARE_WITH_CURRENT_CONTEXT, - SDL_GL_FRAMEBUFFER_SRGB_CAPABLE - } - - /// <summary> - /// An enumeration of OpenGL profiles. - /// </summary> - [Flags] - public enum SDL_GLprofile - { - SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, - SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, - SDL_GL_CONTEXT_PROFILE_ES = 0x0004 - } - - /// <summary> - /// This enumeration is used in conjunction with SDL_GL_SetAttribute - /// and SDL_GL_CONTEXT_FLAGS. Multiple flags can be OR'd together. - /// </summary> - [Flags] - public enum SDL_GLcontext - { - SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, - SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, - SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, - SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 - } - - /// <summary> - /// An enumeration of window events. - /// </summary> - public enum SDL_WindowEventID : byte - { - SDL_WINDOWEVENT_NONE, - SDL_WINDOWEVENT_SHOWN, - SDL_WINDOWEVENT_HIDDEN, - SDL_WINDOWEVENT_EXPOSED, - SDL_WINDOWEVENT_MOVED, - SDL_WINDOWEVENT_RESIZED, - SDL_WINDOWEVENT_SIZE_CHANGED, - SDL_WINDOWEVENT_MINIMIZED, - SDL_WINDOWEVENT_MAXIMIZED, - SDL_WINDOWEVENT_RESTORED, - SDL_WINDOWEVENT_ENTER, - SDL_WINDOWEVENT_LEAVE, - SDL_WINDOWEVENT_FOCUS_GAINED, - SDL_WINDOWEVENT_FOCUS_LOST, - SDL_WINDOWEVENT_CLOSE, - } - - /// <summary> - /// An enumeration of window states. - /// </summary> - [Flags] - public enum SDL_WindowFlags - { - SDL_WINDOW_FULLSCREEN = 0x00000001, - SDL_WINDOW_OPENGL = 0x00000002, - SDL_WINDOW_SHOWN = 0x00000004, - SDL_WINDOW_HIDDEN = 0x00000008, - SDL_WINDOW_BORDERLESS = 0x00000010, - SDL_WINDOW_RESIZABLE = 0x00000020, - SDL_WINDOW_MINIMIZED = 0x00000040, - SDL_WINDOW_MAXIMIZED = 0x00000080, - SDL_WINDOW_INPUT_GRABBED = 0x00000100, - SDL_WINDOW_INPUT_FOCUS = 0x00000200, - SDL_WINDOW_MOUSE_FOCUS = 0x00000400, - SDL_WINDOW_FULLSCREEN_DESKTOP = - (SDL_WINDOW_FULLSCREEN | 0x00001000), - SDL_WINDOW_FOREIGN = 0x00000800, - SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /* Only available in 2.0.1 */ - } - - public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; - public const int SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000; - public const int SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000; - public const int SDL_WINDOWPOS_CENTERED = 0x2FFF0000; - - public static int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int X) - { - return (SDL_WINDOWPOS_UNDEFINED_MASK | X); - } - - public static bool SDL_WINDOWPOS_ISUNDEFINED(int X) - { - return (X & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK; - } - - public static int SDL_WINDOWPOS_CENTERED_DISPLAY(int X) - { - return (SDL_WINDOWPOS_CENTERED_MASK | X); - } - - public static bool SDL_WINDOWPOS_ISCENTERED(int X) - { - return (X & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK; - } - - /// <summary> - /// A structure that describes a display mode. - /// </summary> - [StructLayout(LayoutKind.Sequential)] - public struct SDL_DisplayMode - { - public uint format; - public int w; - public int h; - public int refresh_rate; - public IntPtr driverdata; // void* - } - - /// <summary> - /// Use this function to create a window with the specified position, dimensions, and flags. - /// </summary> - /// <param name="title">the title of the window, in UTF-8 encoding</param> - /// <param name="x">the x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED</param> - /// <param name="y">the y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED</param> - /// <param name="w">the width of the window</param> - /// <param name="h">the height of the window</param> - /// <param name="flags">0, or one or more <see cref="SDL_WindowFlags"/> OR'd together; - /// see Remarks for details</param> - /// <returns>Returns the window that was created or NULL on failure; call <see cref="SDL_GetError()"/> - /// for more information. (refers to an <see cref="SDL_Window"/>)</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_CreateWindow( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string title, - int x, - int y, - int w, - int h, - SDL_WindowFlags flags - ); - - /// <summary> - /// Use this function to create a window and default renderer. - /// </summary> - /// <param name="width">The width of the window</param> - /// <param name="height">The height of the window</param> - /// <param name="window_flags">The flags used to create the window (see <see cref="SDL_CreateWindow()"/>)</param> - /// <param name="window">A pointer filled with the window, or NULL on error (<see cref="SDL_Window*"/>)</param> - /// <param name="renderer">A pointer filled with the renderer, or NULL on error <see cref="(SDL_Renderer*)"/></param> - /// <returns>Returns 0 on success, or -1 on error; call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_CreateWindowAndRenderer( - int width, - int height, - SDL_WindowFlags window_flags, - out IntPtr window, - out IntPtr renderer - ); - - /// <summary> - /// Use this function to create an SDL window from an existing native window. - /// </summary> - /// <param name="data">a pointer to driver-dependent window creation data, typically your native window cast to a void*</param> - /// <returns>Returns the window (<see cref="SDL_Window"/>) that was created or NULL on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_CreateWindowFrom(IntPtr data); - - /// <summary> - /// Use this function to destroy a window. - /// </summary> - /// <param name="window">the window to destroy (<see cref="SDL_Window"/>)</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_DestroyWindow(IntPtr window); - - /// <summary> - /// Use this function to prevent the screen from being blanked by a screen saver. - /// </summary> - /// <remarks>If you disable the screensaver, it is automatically re-enabled when SDL quits. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_DisableScreenSaver(); - - /// <summary> - /// Use this function to allow the screen to be blanked by a screen saver. - /// </summary> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_EnableScreenSaver(); - - /* IntPtr refers to an SDL_DisplayMode. Just use closest. */ - /// <summary> - /// Use this function to get the closest match to the requested display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure containing the desired display mode </param> - /// <param name="closest">an <see cref="SDL_DisplayMode"/> structure filled in with - /// the closest match of the available display modes </param> - /// <returns>Returns the passed in value closest or NULL if no matching video mode was available; - /// (refers to a <see cref="SDL_DisplayMode"/>) - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>The available display modes are scanned and closest is filled in with the closest mode - /// matching the requested mode and returned. The mode format and refresh rate default to the desktop - /// mode if they are set to 0. The modes are scanned with size being first priority, format being - /// second priority, and finally checking the refresh rate. If all the available modes are too small, - /// then NULL is returned. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_GetClosestDisplayMode( - int displayIndex, - ref SDL_DisplayMode mode, - out SDL_DisplayMode closest - ); - - /// <summary> - /// Use this function to get information about the current display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the current display mode</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>There's a difference between this function and <see cref="SDL_GetDesktopDisplayMode"/> when SDL - /// runs fullscreen and has changed the resolution. In that case this function will return the - /// current display mode, and not the previous native display mode. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetCurrentDisplayMode( - int displayIndex, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to return the name of the currently initialized video driver. - /// </summary> - /// <returns>Returns the name of the current video driver or NULL if no driver has been initialized. </returns> - /// <remarks>There's a difference between this function and <see cref="SDL_GetCurrentDisplayMode"/> when SDL - /// runs fullscreen and has changed the resolution. In that case this function will return the - /// previous native display mode, and not the current display mode. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetCurrentVideoDriver(); - - /// <summary> - /// Use this function to get information about the desktop display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the current display mode</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>There's a difference between this function and <see cref="SDL_GetCurrentDisplayMode"/> when SDL - /// runs fullscreen and has changed the resolution. In that case this function will return the - /// previous native display mode, and not the current display mode. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetDesktopDisplayMode( - int displayIndex, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to get the desktop area represented by a display, with the primary display located at 0,0. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="rect">the <see cref="SDL_Rect"/> structure filled in with the display bounds</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetDisplayBounds( - int displayIndex, - out SDL_Rect rect - ); - - /// <summary> - /// Use this function to get information about a specific display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="modeIndex">the index of the display mode to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the mode at modeIndex</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>The display modes are sorted in this priority: - /// <remarks>bits per pixel -> more colors to fewer colors</remarks> - /// <remarks>width -> largest to smallest</remarks> - /// <remarks>height -> largest to smallest</remarks> - /// <remarks>refresh rate -> highest to lowest</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetDisplayMode( - int displayIndex, - int modeIndex, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to return the number of available display modes. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <returns>Returns a number >= 1 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetNumDisplayModes( - int displayIndex - ); - - /// <summary> - /// Use this function to return the number of available video displays. - /// </summary> - /// <returns>Returns a number >= 1 or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetNumVideoDisplays(); - - /// <summary> - /// Use this function to get the number of video drivers compiled into SDL. - /// </summary> - /// <returns>Returns a number >= 1 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetNumVideoDrivers(); - - /// <summary> - /// Use this function to get the name of a built in video driver. - /// </summary> - /// <param name="index">the index of a video driver</param> - /// <returns>Returns the name of the video driver with the given index. </returns> - /// <remarks>The video drivers are presented in the order in which they are normally checked during initialization. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetVideoDriver( - int index - ); - - /// <summary> - /// Use this function to get the brightness (gamma correction) for a window. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <returns>Returns the brightness for the window where 0.0 is completely dark and 1.0 is normal brightness. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float SDL_GetWindowBrightness( - IntPtr window - ); - - /// <summary> - /// Use this function to retrieve the data pointer associated with a window. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <param name="name">the name of the pointer</param> - /// <returns>Returns the value associated with name. (void*)</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_GetWindowData( - IntPtr window, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name - ); - - /// <summary> - /// Use this function to get the index of the display associated with a window. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <returns>Returns the index of the display containing the center of the window - /// on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetWindowDisplayIndex( - IntPtr window - ); - - /// <summary> - /// Use this function to fill in information about the display mode to use when a window is visible at fullscreen. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the fullscreen display mode</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetWindowDisplayMode( - IntPtr window, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to get the window flags. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <returns>Returns a mask of the <see cref="SDL_WindowFlags"/> associated with window; see Remarks for details.</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint SDL_GetWindowFlags(IntPtr window); - - /// <summary> - /// Use this function to get a window from a stored ID. - /// </summary> - /// <param name="id">the ID of the window</param> - /// <returns>Returns the window associated with id or NULL if it doesn't exist (<see cref="SDL_Window"/>); - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_GetWindowFromID(uint id); - - /* window refers to an SDL_Window* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetWindowGammaRamp( - IntPtr window, - [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] - ushort[] red, - [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] - ushort[] green, - [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] - ushort[] blue - ); - - /* window refers to an SDL_Window* */ - [DllImport(nativeLibName, CallingConven... [truncated message content] |
From: <ka...@us...> - 2014-08-03 17:32:45
|
Revision: 1434 http://sourceforge.net/p/agate/code/1434 Author: kanato Date: 2014-08-03 17:32:32 +0000 (Sun, 03 Aug 2014) Log Message: ----------- Make SDL work with 32/64 bit. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs trunk/AgateLib/InputLib/ImplementationBase/InputImpl.cs trunk/AgateLib/InputLib/JoystickInput.cs trunk/AgateLib-Everything.sln trunk/AgateLib.AgateSDL/Audio/SDL_Audio.cs trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs trunk/AgateLib.AgateSDL/Audio/SDL_SoundBufferSession.cs trunk/AgateLib.AgateSDL/Input/SDL_Input.cs trunk/AgateLib.AgateSDL/Sdl2/ISDL.cs trunk/AgateLib.AgateSDL/Sdl2/ISDLMixer.cs trunk/AgateLib.AgateSDL/Sdl2/SDL32.cs trunk/AgateLib.AgateSDL/Sdl2/SDL64.cs trunk/AgateLib.AgateSDL/Sdl2/SDLConstants.cs trunk/AgateLib.AgateSDL/Sdl2/SdlFactory.cs trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2_mixer.cs trunk/AgateLib.GL/AgateLib.GL.csproj trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/AgateLib.Platform.WindowsForms/Factories/SdlFactory.cs Added Paths: ----------- trunk/AgateLib.AgateSDL/ trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.dll.config Removed Paths: ------------- trunk/AgateLib.AgateSDL/AgateLib.SDL.csproj trunk/AgateLib.AgateSDL/AgateLib.SDL.dll.config trunk/AgateLib.SDL/ Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib/AgateLib.csproj 2014-08-03 17:32:32 UTC (rev 1434) @@ -20,7 +20,7 @@ <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> + <OutputPath>..\Binaries\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> @@ -29,7 +29,7 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> + <OutputPath>..\Binaries\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -161,7 +161,7 @@ { Initialize(); AutoCreateDisplayWindow(); - Display.RenderState.WaitForVerticalBlank = Parameters.VerticalSync; + //Display.RenderState.WaitForVerticalBlank = Parameters.VerticalSync; int retval = BeginModel(entryPoint); Modified: trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs =================================================================== --- trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -46,5 +46,9 @@ { return new List<JoystickImpl>(); } + + public override void Poll() + { + } } } Modified: trunk/AgateLib/InputLib/ImplementationBase/InputImpl.cs =================================================================== --- trunk/AgateLib/InputLib/ImplementationBase/InputImpl.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib/InputLib/ImplementationBase/InputImpl.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -39,5 +39,7 @@ /// </summary> /// <returns></returns> public abstract IEnumerable<JoystickImpl> CreateJoysticks(); + + public abstract void Poll(); } } Modified: trunk/AgateLib/InputLib/JoystickInput.cs =================================================================== --- trunk/AgateLib/InputLib/JoystickInput.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib/InputLib/JoystickInput.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -64,6 +64,8 @@ internal static void PollTimer() { + sImpl.Poll(); + for (int i = 0; i < mRawJoysticks.Count; i++) mRawJoysticks[i].Poll(); } Modified: trunk/AgateLib-Everything.sln =================================================================== --- trunk/AgateLib-Everything.sln 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib-Everything.sln 2014-08-03 17:32:32 UTC (rev 1434) @@ -35,7 +35,7 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.Platform.WindowsForms", "AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj", "{4B12561E-D37B-48A1-B6DB-218E94906C22}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.SDL", "AgateLib.SDL\AgateLib.SDL.csproj", "{935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.AgateSDL", "AgateLib.AgateSDL\AgateLib.AgateSDL.csproj", "{935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Copied: trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj (from rev 1433, trunk/AgateLib.SDL/AgateLib.SDL.csproj) =================================================================== --- trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj (rev 0) +++ trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.csproj 2014-08-03 17:32:32 UTC (rev 1434) @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>AgateLib.AgateSDL</RootNamespace> + <AssemblyName>AgateLib.SDL</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\Binaries\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\Binaries\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Audio\SDL_Audio.cs" /> + <Compile Include="Audio\SDL_Music.cs" /> + <Compile Include="Audio\SDL_SoundBuffer.cs" /> + <Compile Include="Audio\SDL_SoundBufferSession.cs" /> + <Compile Include="Input\SDL_Input.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Sdl2\ISDL.cs" /> + <Compile Include="Sdl2\ISDLMixer.cs" /> + <Compile Include="Sdl2\SDL32.cs" /> + <Compile Include="Sdl2\SDL64.cs" /> + <Compile Include="Sdl2\SDLConstants.cs" /> + <Compile Include="Sdl2\SdlFactory.cs" /> + <Compile Include="Sdl2\SixtyFour\LPUtf8StrMarshaler.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2_image.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2_mixer.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2_ttf.cs" /> + <Compile Include="Sdl2\ThirtyTwo\LPUtf8StrMarshaler.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2_image.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2_mixer.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2_ttf.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="AgateLib.AgateSDL.dll.config" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <None Include="lib64\Readme-SDL.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\AgateLib\AgateLib.csproj"> + <Project>{9490b719-829e-43a7-a5fe-8001f8a81759}</Project> + <Name>AgateLib</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Content Include="lib32\libFLAC-8.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libmikmod-2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libmodplug-1.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libogg-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libvorbis-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libvorbisfile-3.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.FLAC.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.mikmod.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.modplug.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.ogg-vorbis.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.smpeg.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\README-SDL.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\README.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\SDL2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\SDL2_mixer.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\smpeg2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libFLAC-8.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libmikmod-2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libmodplug-1.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libogg-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libvorbis-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libvorbisfile-3.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.FLAC.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.mikmod.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.modplug.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.ogg-vorbis.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.smpeg.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\README.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\SDL2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\SDL2_mixer.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\smpeg2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + </ItemGroup> + <ItemGroup /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Copied: trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.dll.config (from rev 1433, trunk/AgateLib.SDL/AgateLib.SDL.dll.config) =================================================================== --- trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.dll.config (rev 0) +++ trunk/AgateLib.AgateSDL/AgateLib.AgateSDL.dll.config 2014-08-03 17:32:32 UTC (rev 1434) @@ -0,0 +1,6 @@ +<configuration> + <dllmap os="linux" dll="SDL.dll" target="libSDL-1.2.so.0"/> + <dllmap os="linux" dll="SDL_mixer.dll" target="libSDL_mixer-1.2.so.0"/> + <dllmap os="osx" dll="SDL.dll" target="SDL.framework/SDL"/> + <dllmap os="osx" dll="SDL_mixer.dll" target="SDL_mixer.framework/SDL_mixer"/> +</configuration> Deleted: trunk/AgateLib.AgateSDL/AgateLib.SDL.csproj =================================================================== --- trunk/AgateLib.SDL/AgateLib.SDL.csproj 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/AgateLib.SDL.csproj 2014-08-03 17:32:32 UTC (rev 1434) @@ -1,188 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>AgateLib.SDL</RootNamespace> - <AssemblyName>AgateLib.SDL</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Audio\SDL_Audio.cs" /> - <Compile Include="Audio\SDL_Music.cs" /> - <Compile Include="Audio\SDL_SoundBuffer.cs" /> - <Compile Include="Audio\SDL_SoundBufferSession.cs" /> - <Compile Include="Input\SDL_Input.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Sdl2\ISDL.cs" /> - <Compile Include="Sdl2\ISDLMixer.cs" /> - <Compile Include="Sdl2\SDL32.cs" /> - <Compile Include="Sdl2\SDL64.cs" /> - <Compile Include="Sdl2\SDLConstants.cs" /> - <Compile Include="Sdl2\SdlFactory.cs" /> - <Compile Include="Sdl2\SixtyFour\LPUtf8StrMarshaler.cs" /> - <Compile Include="Sdl2\SixtyFour\SDL2.cs" /> - <Compile Include="Sdl2\SixtyFour\SDL2_image.cs" /> - <Compile Include="Sdl2\SixtyFour\SDL2_mixer.cs" /> - <Compile Include="Sdl2\SixtyFour\SDL2_ttf.cs" /> - <Compile Include="Sdl2\ThirtyTwo\LPUtf8StrMarshaler.cs" /> - <Compile Include="Sdl2\ThirtyTwo\SDL2.cs" /> - <Compile Include="Sdl2\ThirtyTwo\SDL2_image.cs" /> - <Compile Include="Sdl2\ThirtyTwo\SDL2_mixer.cs" /> - <Compile Include="Sdl2\ThirtyTwo\SDL2_ttf.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="AgateLib.SDL.dll.config"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - <None Include="packages.config" /> - </ItemGroup> - <ItemGroup> - <None Include="lib64\Readme-SDL.txt"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\AgateLib\AgateLib.csproj"> - <Project>{9490b719-829e-43a7-a5fe-8001f8a81759}</Project> - <Name>AgateLib</Name> - </ProjectReference> - </ItemGroup> - <ItemGroup> - <Content Include="lib32\libFLAC-8.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\libmikmod-2.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\libmodplug-1.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\libogg-0.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\libvorbis-0.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\libvorbisfile-3.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\LICENSE.FLAC.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\LICENSE.mikmod.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\LICENSE.modplug.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\LICENSE.ogg-vorbis.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\LICENSE.smpeg.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\README-SDL.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\README.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\SDL2.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\SDL2_mixer.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib32\smpeg2.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\libFLAC-8.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\libmikmod-2.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\libmodplug-1.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\libogg-0.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\libvorbis-0.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\libvorbisfile-3.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\LICENSE.FLAC.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\LICENSE.mikmod.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\LICENSE.modplug.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\LICENSE.ogg-vorbis.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\LICENSE.smpeg.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\README.txt"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\SDL2.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\SDL2_mixer.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - <Content Include="lib64\smpeg2.dll"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - </ItemGroup> - <ItemGroup /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> \ No newline at end of file Deleted: trunk/AgateLib.AgateSDL/AgateLib.SDL.dll.config =================================================================== --- trunk/AgateLib.SDL/AgateLib.SDL.dll.config 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/AgateLib.SDL.dll.config 2014-08-03 17:32:32 UTC (rev 1434) @@ -1,6 +0,0 @@ -<configuration> - <dllmap os="linux" dll="SDL.dll" target="libSDL-1.2.so.0"/> - <dllmap os="linux" dll="SDL_mixer.dll" target="libSDL_mixer-1.2.so.0"/> - <dllmap os="osx" dll="SDL.dll" target="SDL.framework/SDL"/> - <dllmap os="osx" dll="SDL_mixer.dll" target="SDL_mixer.framework/SDL_mixer"/> -</configuration> Modified: trunk/AgateLib.AgateSDL/Audio/SDL_Audio.cs =================================================================== --- trunk/AgateLib.SDL/Audio/SDL_Audio.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Audio/SDL_Audio.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -23,15 +23,15 @@ using AgateLib; using AgateLib.AudioLib.ImplementationBase; using SDL2; -using AgateLib.SDL.Sdl2; +using AgateLib.AgateSDL.Sdl2; -namespace AgateLib.SDL.Audio +namespace AgateLib.AgateSDL.Audio { public class SDL_Audio : AudioImpl { List<string> tempfiles = new List<string>(); Dictionary<int, SDL_SoundBufferSession> mChannels = new Dictionary<int, SDL_SoundBufferSession>(); - Func<int> mChannelFinishedDelegate; + Action<int> mChannelFinishedDelegate; ISDL sdl; public SDL_Audio() @@ -117,7 +117,7 @@ } if (sdl.Mixer.Mix_OpenAudio( - sdl.Mixer.MIX_DEFAULT_FREQUENCY, SDLConstants.AUDIO_S16, 2, 512) != 0) + SDLConstants.MIX_DEFAULT_FREQUENCY, SDLConstants.AUDIO_S16, 2, 512) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL_mixer."); } Modified: trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs =================================================================== --- trunk/AgateLib.SDL/Audio/SDL_Music.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Audio/SDL_Music.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -23,11 +23,13 @@ using AgateLib; using AgateLib.AudioLib.ImplementationBase; using SDL2; +using AgateLib.AgateSDL.Sdl2; -namespace AgateLib.SDL.Audio +namespace AgateLib.AgateSDL.Audio { public class SDL_Music : MusicImpl { + ISDL sdl; SDL_Audio audio; IntPtr music; string tempfile; @@ -47,6 +49,8 @@ public SDL_Music(SDL_Audio audio, string filename) { + sdl = SdlFactory.CreateSDL(); + this.audio = audio; LoadFromFile(filename); @@ -65,7 +69,7 @@ private void Dispose(bool disposing) { - SDL_mixer.Mix_FreeMusic(music); + sdl.Mixer.Mix_FreeMusic(music); //if (string.IsNullOrEmpty(tempfile) == false) //{ @@ -76,7 +80,7 @@ private void LoadFromFile(string file) { - music = SDL_mixer.Mix_LoadMUS(file); + music = sdl.Mixer.Mix_LoadMUS(file); if (music == IntPtr.Zero) throw new AgateException("Could not load music file."); @@ -86,10 +90,10 @@ { get { - if (SDL_mixer.Mix_PlayingMusic() == 0) + if (sdl.Mixer.Mix_PlayingMusic() == 0) return false; - if (SDL_mixer.Mix_PausedMusic() != 0) + if (sdl.Mixer.Mix_PausedMusic() != 0) return false; return true; @@ -98,7 +102,7 @@ protected override void OnSetLoop(bool value) { - SDL_mixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); + sdl.Mixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); } public override double Pan @@ -115,13 +119,13 @@ public override void Play() { - SDL_mixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); - mVolume = SDL_mixer.Mix_VolumeMusic(-1) / (double)SDL_mixer.MIX_MAX_VOLUME; + sdl.Mixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); + mVolume = sdl.Mixer.Mix_VolumeMusic(-1) / (double)SDLConstants.MIX_MAX_VOLUME; } public override void Stop() { - SDL_mixer.Mix_PauseMusic(); + sdl.Mixer.Mix_PauseMusic(); } public override double Volume @@ -136,9 +140,9 @@ if (mVolume < 0) mVolume = 0; if (mVolume > 1) mVolume = 1; - int v = (int)(mVolume * SDL_mixer.MIX_MAX_VOLUME); + int v = (int)(mVolume * SDLConstants.MIX_MAX_VOLUME); - SDL_mixer.Mix_VolumeMusic(v); + sdl.Mixer.Mix_VolumeMusic(v); } } } Modified: trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs =================================================================== --- trunk/AgateLib.SDL/Audio/SDL_SoundBuffer.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Audio/SDL_SoundBuffer.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -23,12 +23,13 @@ using System.Text; using AgateLib; using AgateLib.AudioLib.ImplementationBase; -using SDL2; +using AgateLib.AgateSDL.Sdl2; -namespace AgateLib.SDL.Audio +namespace AgateLib.AgateSDL.Audio { class SDL_SoundBuffer : SoundBufferImpl { + ISDL sdl; IntPtr sound; string tempfile; double mVolume = 1.0; @@ -48,6 +49,8 @@ } public SDL_SoundBuffer(string filename) { + sdl = SdlFactory.CreateSDL(); + this.filename = filename; LoadFromFile(filename); } @@ -73,7 +76,7 @@ private void Dispose(bool disposing) { - SDL_mixer.Mix_FreeChunk(sound); + sdl.Mixer.Mix_FreeChunk(sound); //if (string.IsNullOrEmpty(tempfile) == false) //{ // File.Delete(tempfile); @@ -82,7 +85,7 @@ } private void LoadFromFile(string file) { - sound = SDL_mixer.Mix_LoadWAV(file); + sound = sdl.Mixer.Mix_LoadWAV(file); if (sound == IntPtr.Zero) throw new AgateException("Could not load audio file."); Modified: trunk/AgateLib.AgateSDL/Audio/SDL_SoundBufferSession.cs =================================================================== --- trunk/AgateLib.SDL/Audio/SDL_SoundBufferSession.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Audio/SDL_SoundBufferSession.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -24,11 +24,13 @@ using AgateLib; using AgateLib.AudioLib.ImplementationBase; using SDL2; +using AgateLib.AgateSDL.Sdl2; -namespace AgateLib.SDL.Audio +namespace AgateLib.AgateSDL.Audio { class SDL_SoundBufferSession : SoundBufferSessionImpl { + ISDL sdl; IntPtr sound; int channel = -1; double volume; @@ -42,6 +44,8 @@ public SDL_SoundBufferSession(SDL_SoundBuffer buffer) { + sdl = SdlFactory.CreateSDL(); + this.buffer = buffer; loop = buffer.Loop; @@ -49,6 +53,8 @@ volume = buffer.Volume; audio = (SDL_Audio)AgateLib.AudioLib.Audio.Impl; + + Debug.Print("Playing " + buffer.Filename); } public override void Dispose() { @@ -67,7 +73,7 @@ if (channel == -1) return false; - return SDL_mixer.Mix_Playing(channel) != 0; + return sdl.Mixer.Mix_Playing(channel) != 0; } } @@ -100,21 +106,21 @@ byte leftVol = (byte)(pan <= 0 ? 255 : (int)((1.0 - pan) * 255)); byte rightVol = (byte)(pan >= 0 ? 255 : (int)((pan + 1.0) * 255)); - SDL_mixer.Mix_SetPanning(channel, leftVol, rightVol); + sdl.Mixer.Mix_SetPanning(channel, leftVol, rightVol); } public override void Play() { if (IsPlaying == false) { - channel = SDL_mixer.Mix_PlayChannel(-1, sound, LoopCount); + channel = sdl.Mixer.Mix_PlayChannel(-1, sound, LoopCount); if (channel == -1) Trace.WriteLine(string.Format("Error: {0}", "unknown" /*SDL_mixer.Mix_GetError() */)); } else { - SDL_mixer.Mix_PlayChannel(channel, sound, LoopCount); + sdl.Mixer.Mix_PlayChannel(channel, sound, LoopCount); } SetPanning(); @@ -142,7 +148,7 @@ public override void Stop() { - SDL_mixer.Mix_HaltChannel(channel); + sdl.Mixer.Mix_HaltChannel(channel); watch.Stop(); } @@ -165,7 +171,7 @@ { if (channel != -1) { - SDL_mixer.Mix_Volume(channel, (int)(volume * 128)); + sdl.Mixer.Mix_Volume(channel, (int)(volume * 128)); } } @@ -176,7 +182,7 @@ if (channel == -1) return false; else - return SDL_mixer.Mix_Paused(channel) != 0; + return sdl.Mixer.Mix_Paused(channel) != 0; } set { @@ -185,11 +191,11 @@ if (IsPaused) { - SDL_mixer.Mix_Resume(channel); + sdl.Mixer.Mix_Resume(channel); } else { - SDL_mixer.Mix_Pause(channel); + sdl.Mixer.Mix_Pause(channel); } } } Modified: trunk/AgateLib.AgateSDL/Input/SDL_Input.cs =================================================================== --- trunk/AgateLib.SDL/Input/SDL_Input.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Input/SDL_Input.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -22,61 +22,73 @@ using System.Text; using AgateLib.Drivers; using AgateLib.InputLib.ImplementationBase; +using AgateLib.AgateSDL.Sdl2; -namespace AgateLib.SDL.Input +namespace AgateLib.AgateSDL.Input { public class SDL_Input : InputImpl { + ISDL sdl; + public SDL_Input() { + sdl = SdlFactory.CreateSDL(); } public override int JoystickCount { - get { return SDL2.SDL.SDL_NumJoysticks(); } + get { return sdl.SDL_NumJoysticks(); } } public override IEnumerable<JoystickImpl> CreateJoysticks() { for (int i = 0; i < JoystickCount; i++) { - Debug.Print(SDL2.SDL.SDL_JoystickName((IntPtr)i)); + Debug.Print(sdl.SDL_JoystickName((IntPtr)i)); yield return new Joystick_SDL(i); } } public override void Dispose() { - SDL2.SDL.SDL_QuitSubSystem(SDL2.SDL.SDL_INIT_JOYSTICK); + sdl.SDL_QuitSubSystem(SDLConstants.SDL_INIT_JOYSTICK); } public override void Initialize() { // apparently initializing the video has some side-effect // that is required for joysticks to work on windows (at least). - if (SDL2.SDL.SDL_InitSubSystem(SDL2.SDL.SDL_INIT_JOYSTICK | SDL2.SDL.SDL_INIT_VIDEO) != 0) + if (sdl.SDL_InitSubSystem(SDLConstants.SDL_INIT_JOYSTICK | SDLConstants.SDL_INIT_VIDEO) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL joysticks."); } + + sdl.SDL_SetHint("SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS", "1"); - SDL2.SDL.SDL_version version; - SDL2.SDL.SDL_VERSION(out version); + Report("SDL driver version 2.0.3 instantiated for joystick input."); + } - Report("SDL driver version " + version.ToString() + " instantiated for joystick input."); - + public override void Poll() + { + sdl.CallPollEvent(); } } public class Joystick_SDL : JoystickImpl { + ISDL sdl; + IntPtr joystick; IntPtr joystickIndex; double axisTheshold = 0.04f; bool[] buttons; + int buttonCount = -1; public Joystick_SDL(int index) { + sdl = SdlFactory.CreateSDL(); + this.joystickIndex = (IntPtr) index; - this.joystick = SDL2.SDL.SDL_JoystickOpen(index); + this.joystick = sdl.SDL_JoystickOpen(index); buttons = new bool[ButtonCount]; } @@ -84,7 +96,7 @@ { get { - string retval = SDL2.SDL.SDL_JoystickName(joystickIndex); + string retval = sdl.SDL_JoystickName(joystickIndex); return retval; } @@ -92,11 +104,11 @@ public override int AxisCount { - get { return SDL2.SDL.SDL_JoystickNumAxes(joystick); } + get { return sdl.SDL_JoystickNumAxes(joystick); } } public override int HatCount { - get { return SDL2.SDL.SDL_JoystickNumHats(joystick); } + get { return sdl.SDL_JoystickNumHats(joystick); } } public override double AxisThreshold @@ -113,7 +125,13 @@ public override int ButtonCount { - get { return SDL2.SDL.SDL_JoystickNumButtons(joystick); } + get + { + if (buttonCount == -1) + buttonCount = sdl.SDL_JoystickNumButtons(joystick); + + return buttonCount; + } } public override bool GetButtonState(int buttonIndex) @@ -122,18 +140,18 @@ } public override AgateLib.InputLib.HatState GetHatState(int hatIndex) { - switch(SDL2.SDL.SDL_JoystickGetHat(joystick, hatIndex)) + switch(sdl.SDL_JoystickGetHat(joystick, hatIndex)) { - case SDL2.SDL.SDL_HAT_RIGHTUP: return AgateLib.InputLib.HatState.UpRight; - case SDL2.SDL.SDL_HAT_RIGHT: return AgateLib.InputLib.HatState.Right; - case SDL2.SDL.SDL_HAT_RIGHTDOWN: return AgateLib.InputLib.HatState.DownRight; - case SDL2.SDL.SDL_HAT_LEFTUP: return AgateLib.InputLib.HatState.UpLeft; - case SDL2.SDL.SDL_HAT_LEFT: return AgateLib.InputLib.HatState.Left; - case SDL2.SDL.SDL_HAT_LEFTDOWN: return AgateLib.InputLib.HatState.DownLeft; - case SDL2.SDL.SDL_HAT_DOWN: return AgateLib.InputLib.HatState.Down; - case SDL2.SDL.SDL_HAT_UP: return AgateLib.InputLib.HatState.Up; + case SDLConstants.SDL_HAT_RIGHTUP: return AgateLib.InputLib.HatState.UpRight; + case SDLConstants.SDL_HAT_RIGHT: return AgateLib.InputLib.HatState.Right; + case SDLConstants.SDL_HAT_RIGHTDOWN: return AgateLib.InputLib.HatState.DownRight; + case SDLConstants.SDL_HAT_LEFTUP: return AgateLib.InputLib.HatState.UpLeft; + case SDLConstants.SDL_HAT_LEFT: return AgateLib.InputLib.HatState.Left; + case SDLConstants.SDL_HAT_LEFTDOWN: return AgateLib.InputLib.HatState.DownLeft; + case SDLConstants.SDL_HAT_DOWN: return AgateLib.InputLib.HatState.Down; + case SDLConstants.SDL_HAT_UP: return AgateLib.InputLib.HatState.Up; - case SDL2.SDL.SDL_HAT_CENTERED: + case SDLConstants.SDL_HAT_CENTERED: default: return AgateLib.InputLib.HatState.None; } @@ -141,7 +159,7 @@ public override double GetAxisValue(int axisIndex) { // Convert joystick coordinate to the agatelib coordinate system of -1..1. - double value = SDL2.SDL.SDL_JoystickGetAxis(joystick, axisIndex) / 32767.0; + double value = sdl.SDL_JoystickGetAxis(joystick, axisIndex) / 32767.0; if (value < -1) value = -1; else if (value > 1) value = 1; @@ -159,12 +177,9 @@ public override void Poll() { - SDL2.SDL.SDL_Event evt; - SDL2.SDL.SDL_PollEvent(out evt); - for (int i = 0; i < ButtonCount; i++) { - buttons[i] = (SDL2.SDL.SDL_JoystickGetButton(joystick, i) != 0) ? true : false; + buttons[i] = (sdl.SDL_JoystickGetButton(joystick, i) != 0) ? true : false; } } Modified: trunk/AgateLib.AgateSDL/Sdl2/ISDL.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/ISDL.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/ISDL.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -3,12 +3,36 @@ using System.Linq; using System.Text; -namespace AgateLib.SDL.Sdl2 +namespace AgateLib.AgateSDL.Sdl2 { interface ISDL { ISDLMixer Mixer { get; } - void SDL_QuitSubSystem(uint p); + void SDL_QuitSubSystem(uint flags); + + int SDL_InitSubSystem(uint flags); + + int SDL_NumJoysticks(); + + string SDL_JoystickName(IntPtr joystick); + + IntPtr SDL_JoystickOpen(int index); + + int SDL_JoystickNumAxes(IntPtr joystick); + + int SDL_JoystickNumHats(IntPtr joystick); + + int SDL_JoystickNumButtons(IntPtr joystick); + + int SDL_JoystickGetHat(IntPtr joystick, int hatIndex); + + double SDL_JoystickGetAxis(IntPtr joystick, int axisIndex); + + int SDL_JoystickGetButton(IntPtr joystick, int i); + + void CallPollEvent(); + + void SDL_SetHint(string p1, string p2); } } Modified: trunk/AgateLib.AgateSDL/Sdl2/ISDLMixer.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/ISDLMixer.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/ISDLMixer.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -4,10 +4,50 @@ using System.Text; using System.Threading.Tasks; -namespace AgateLib.SDL.Sdl2 +namespace AgateLib.AgateSDL.Sdl2 { interface ISDLMixer { void Mix_CloseAudio(); + + void Mix_ChannelFinished(Action<int> channelFinished); + + void Mix_AllocateChannels(int numchans); + + int Mix_OpenAudio(int frequency, ushort format, int channels, int chunksize); + + void Mix_FreeMusic(IntPtr music); + + IntPtr Mix_LoadMUS(string file); + + int Mix_PlayingMusic(); + + int Mix_PausedMusic(); + + void Mix_PlayMusic(IntPtr music, int p); + + double Mix_VolumeMusic(int p); + + void Mix_PauseMusic(); + + void Mix_FreeChunk(IntPtr sound); + + IntPtr Mix_LoadWAV(string file); + + int Mix_Playing(int channel); + + void Mix_SetPanning(int channel, byte leftVol, byte rightVol); + + int Mix_PlayChannel(int p, IntPtr sound, int LoopCount); + + void Mix_HaltChannel(int channel); + + void Mix_Volume(int channel, int p); + + int Mix_Paused(int channel); + + void Mix_Resume(int channel); + + void Mix_Pause(int channel); } } Modified: trunk/AgateLib.AgateSDL/Sdl2/SDL32.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/SDL32.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/SDL32.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -4,7 +4,7 @@ using System.Text; using SDL2.ThirtyTwo; -namespace AgateLib.SDL.Sdl2 +namespace AgateLib.AgateSDL.Sdl2 { class SDL32 : ISDL { @@ -15,19 +15,193 @@ get { return mixer; } } + public void SDL_QuitSubSystem(uint flags) + { + SDL.SDL_QuitSubSystem(flags); + } - public void SDL_QuitSubSystem(uint p) + public int SDL_InitSubSystem(uint flags) { - SDL2.ThirtyTwo.SDL.SDL_QuitSubSystem(p); + return SDL.SDL_InitSubSystem(flags); } + + + public int SDL_NumJoysticks() + { + return SDL.SDL_NumJoysticks(); + } + + public string SDL_JoystickName(IntPtr joystick) + { + return SDL.SDL_JoystickName(joystick); + } + + + public IntPtr SDL_JoystickOpen(int index) + { + return SDL.SDL_JoystickOpen(index); + } + + public int SDL_JoystickNumAxes(IntPtr joystick) + { + return SDL.SDL_JoystickNumAxes(joystick); + } + + public int SDL_JoystickNumHats(IntPtr joystick) + { + return SDL.SDL_JoystickNumHats(joystick); + } + + public int SDL_JoystickNumButtons(IntPtr joystick) + { + return SDL.SDL_JoystickNumButtons(joystick); + } + + public int SDL_JoystickGetHat(IntPtr joystick, int hatIndex) + { + return SDL.SDL_JoystickGetHat(joystick, hatIndex); + } + + + public double SDL_JoystickGetAxis(IntPtr joystick, int axisIndex) + { + return SDL.SDL_JoystickGetAxis(joystick, axisIndex); + } + + public int SDL_JoystickGetButton(IntPtr joystick, int button) + { + return SDL.SDL_JoystickGetButton(joystick, button); + } + + + public void CallPollEvent() + { + SDL.SDL_Event evt; + SDL.SDL_PollEvent(out evt); + } + + + public void SDL_SetHint(string name, string value) + { + SDL.SDL_SetHint(name, value); + } } class SDLMixer32 : ISDLMixer { - public void Mix_CloseAudio() { SDL_mixer.Mix_CloseAudio(); } + + + SDL_mixer.ChannelFinishedDelegate channelFinishedDelegate; + + public void Mix_ChannelFinished(Action<int> channelFinished) + { + if (channelFinished == null) + throw new ArgumentNullException(); + + channelFinishedDelegate = new SDL_mixer.ChannelFinishedDelegate(channelFinished); + + SDL_mixer.Mix_ChannelFinished(channelFinishedDelegate); + } + + public void Mix_AllocateChannels(int numchans) + { + SDL_mixer.Mix_AllocateChannels(numchans); + } + + + public int Mix_OpenAudio(int frequency, ushort format, int channels, int chunksize) + { + return SDL_mixer.Mix_OpenAudio(frequency, format, channels, chunksize); + } + + + public void Mix_FreeMusic(IntPtr music) + { + SDL_mixer.Mix_FreeMusic(music); + } + + public IntPtr Mix_LoadMUS(string file) + { + return SDL_mixer.Mix_LoadMUS(file); + } + + public int Mix_PlayingMusic() + { + return SDL_mixer.Mix_PlayingMusic(); + } + + public int Mix_PausedMusic() + { + return SDL_mixer.Mix_PausedMusic(); + } + + public void Mix_PlayMusic(IntPtr music, int loop) + { + SDL_mixer.Mix_PlayMusic(music, loop); + } + + public double Mix_VolumeMusic(int volume) + { + return SDL_mixer.Mix_VolumeMusic(volume); + } + + public void Mix_PauseMusic() + { + SDL_mixer.Mix_PauseMusic(); + } + + public void Mix_FreeChunk(IntPtr chunk) + { + SDL_mixer.Mix_FreeChunk(chunk); + } + + public IntPtr Mix_LoadWAV(string file) + { + return SDL_mixer.Mix_LoadWAV(file); + } + + public int Mix_Playing(int channel) + { + return SDL_mixer.Mix_Playing(channel); + } + + public void Mix_SetPanning(int channel, byte left, byte right) + { + SDL_mixer.Mix_SetPanning(channel, left, right); + } + + public int Mix_PlayChannel(int channel, IntPtr chunk, int loops) + { + return SDL_mixer.Mix_PlayChannel(channel, chunk, loops); + } + + public void Mix_HaltChannel(int channel) + { + SDL_mixer.Mix_HaltChannel(channel); + } + + public void Mix_Volume(int channel, int volume) + { + SDL_mixer.Mix_Volume(channel, volume); + } + + public int Mix_Paused(int channel) + { + return SDL_mixer.Mix_Paused(channel); + } + + public void Mix_Resume(int channel) + { + SDL_mixer.Mix_Resume(channel); + } + + public void Mix_Pause(int channel) + { + SDL_mixer.Mix_Pause(channel); + } } } Modified: trunk/AgateLib.AgateSDL/Sdl2/SDL64.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/SDL64.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/SDL64.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -1,12 +1,12 @@ -using System; +using SDL2.SixtyFour; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace AgateLib.SDL.Sdl2 +namespace AgateLib.AgateSDL.Sdl2 { - - class SDL64: ISDL + class SDL64 : ISDL { SDLMixer64 mixer = new SDLMixer64(); @@ -14,14 +14,187 @@ { get { return mixer; } } + + public void SDL_QuitSubSystem(uint p) + { + SDL.SDL_QuitSubSystem(p); + } + + public int SDL_InitSubSystem(uint flags) + { + return SDL.SDL_InitSubSystem(flags); + } + + public int SDL_NumJoysticks() + { + return SDL.SDL_NumJoysticks(); + } + + public string SDL_JoystickName(IntPtr joystick) + { + return SDL.SDL_JoystickName(joystick); + } + public IntPtr SDL_JoystickOpen(int index) + { + return SDL.SDL_JoystickOpen(index); + } + + public int SDL_JoystickNumAxes(IntPtr joystick) + { + return SDL.SDL_JoystickNumAxes(joystick); + } + + public int SDL_JoystickNumHats(IntPtr joystick) + { + return SDL.SDL_JoystickNumHats(joystick); + } + + public int SDL_JoystickNumButtons(IntPtr joystick) + { + return SDL.SDL_JoystickNumButtons(joystick); + } + + public int SDL_JoystickGetHat(IntPtr joystick, int hatIndex) + { + return SDL.SDL_JoystickGetHat(joystick, hatIndex); + } + + public double SDL_JoystickGetAxis(IntPtr joystick, int axisIndex) + { + return SDL.SDL_JoystickGetAxis(joystick, axisIndex); + } + + public int SDL_JoystickGetButton(IntPtr joystick, int button) + { + return SDL.SDL_JoystickGetButton(joystick, button); + } + + public void CallPollEvent() + { + SDL.SDL_Event evt; + SDL.SDL_PollEvent(out evt); + } + public void SDL_SetHint(string name, string value) + { + SDL.SDL_SetHint(name, value); + } } class SDLMixer64 : ISDLMixer { - public void Mix_CloseAudio() { - SDL2.SixtyFour.SDL_mixer.Mix_CloseAudio(); + SDL_mixer.Mix_CloseAudio(); } + + SDL_mixer.ChannelFinishedDelegate channelFinishedDelegate; + + public void Mix_ChannelFinished(Action<int> channelFinished) + { + if (channelFinished == null) + throw new ArgumentNullException(); + + channelFinishedDelegate = new SDL_mixer.ChannelFinishedDelegate(channelFinished); + + SDL_mixer.Mix_ChannelFinished(channelFinishedDelegate); + } + + public void Mix_AllocateChannels(int numchans) + { + SDL_mixer.Mix_AllocateChannels(numchans); + } + + public int Mix_OpenAudio(int frequency, ushort format, int channels, int chunksize) + { + return SDL_mixer.Mix_OpenAudio(frequency, format, channels, chunksize); + } + public void Mix_FreeMusic(IntPtr music) + { + SDL_mixer.Mix_FreeMusic(music); + } + + public IntPtr Mix_LoadMUS(string file) + { + return SDL_mixer.Mix_LoadMUS(file); + } + + public int Mix_PlayingMusic() + { + return SDL_mixer.Mix_PlayingMusic(); + } + + public int Mix_PausedMusic() + { + return SDL_mixer.Mix_PausedMusic(); + } + + public void Mix_PlayMusic(IntPtr music, int loop) + { + if (music == IntPtr.Zero) throw new ArgumentNullException(); + + SDL_mixer.Mix_PlayMusic(music, loop); + } + + public double Mix_VolumeMusic(int volume) + { + return SDL_mixer.Mix_VolumeMusic(volume); + } + + public void Mix_PauseMusic() + { + SDL_mixer.Mix_PauseMusic(); + } + + public void Mix_FreeChunk(IntPtr chunk) + { + SDL_mixer.Mix_FreeChunk(chunk); + } + + public IntPtr Mix_LoadWAV(string file) + { + return SDL_mixer.Mix_LoadWAV(file); + } + + public int Mix_Playing(int channel) + { + return SDL_mixer.Mix_Playing(channel); + } + + public void Mix_SetPanning(int channel, byte left, byte right) + { + SDL_mixer.Mix_SetPanning(channel, left, right); + } + + public int Mix_PlayChannel(int channel, IntPtr chunk, int loops) + { + if (chunk == null) throw new ArgumentNullException(); + + return SDL_mixer.Mix_PlayChannel(channel, chunk, loops); + } + + public void Mix_HaltChannel(int channel) + { + SDL_mixer.Mix_HaltChannel(channel); + } + + public void Mix_Volume(int channel, int volume) + { + SDL_mixer.Mix_Volume(channel, volume); + } + + public int Mix_Paused(int channel) + { + return SDL_mixer.Mix_Paused(channel); + } + + public void Mix_Resume(int channel) + { + SDL_mixer.Mix_Resume(channel); + } + + public void Mix_Pause(int channel) + { + SDL_mixer.Mix_Pause(channel); + } } } Modified: trunk/AgateLib.AgateSDL/Sdl2/SDLConstants.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/SDLConstants.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/SDLConstants.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AgateLib.SDL.Sdl2 +namespace AgateLib.AgateSDL.Sdl2 { class SDLConstants { @@ -54,7 +54,23 @@ SDL_AUDIO_ALLOW_CHANNELS_CHANGE ); - public const int SDL_MIX_MAXVOLUME = 128; + public const int SDL_MIX_MAXVOLUME = 128; + + public static readonly int MIX_DEFAULT_FREQUENCY = 22050; + public static readonly ushort MIX_DEFAULT_FORMAT = + BitConverter.IsLittleEndian ? SDLConstants.AUDIO_S16LSB : SDLConstants.AUDIO_S16MSB; + public static readonly int MIX_DEFAULT_CHANNELS = 2; + public static readonly byte MIX_MAX_VOLUME = 128; + + public const byte SDL_HAT_CENTERED = 0x00; + public const byte SDL_HAT_UP = 0x01; + public const byte SDL_HAT_RIGHT = 0x02; + public const byte SDL_HAT_DOWN = 0x04; + public const byte SDL_HAT_LEFT = 0x08; + public const byte SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP; + public const byte SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN; + public const byte SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP; + public const byte SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN; } } Modified: trunk/AgateLib.AgateSDL/Sdl2/SdlFactory.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/SdlFactory.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/SdlFactory.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AgateLib.SDL.Sdl2 +namespace AgateLib.AgateSDL.Sdl2 { static class SdlFactory { Modified: trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2_mixer.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2_mixer.cs 2014-08-03 00:09:08 UTC (rev 1433) +++ trunk/AgateLib.AgateSDL/Sdl2/ThirtyTwo/SDL2_mixer.cs 2014-08-03 17:32:32 UTC (rev 1434) @@ -1,489 +1,489 @@ -#region License -/* SDL2# - C# Wrapper for SDL2 - * - * Copyright (c) 2013-2014 Ethan Lee. - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in a - * product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source distribution. - * - * Ethan "flibitijibibo" Lee <fli...@fl...> - * - */ -#endregion - -#region Using Statements -using System; -using System.Runtime.InteropServices; +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2014 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee <fli...@fl...> + * + */ #endregion -namespace SDL2.ThirtyTwo -{ - public static class SDL_mixer - { - #region SDL2# Variables - - /* Used by DllImport to load the native library. */ - private const string nativeLibName = "lib64/SDL2_mixer.dll"; - - #endregion - - #region SDL_mixer.h - - /* Similar to the headers, this is the version we're expecting to be - * running with. You will likely want to check this somewhere in your - * program! - */ - public const int SDL_MIXER_MAJOR_VERSION = 2; - public const int SDL_MIXER_MINOR_VERSION = 0; - public const int SDL_MIXER_PATCHLEVEL = 0; - - /* In C, you can redefine this value before including SDL_mixer.h. - * We're not going to allow this in SDL2#, since the value of this - * variable is persistent and not dependent on preprocessor ordering. - */ - public const int MIX_CHANNELS = 8; - - public static readonly int MIX_DEFAULT_FREQUENCY = 22050; - public static readonly ushort MIX_DEFAULT_FORMAT = - BitConverter.IsLittleEndian ? SDL.AUDIO_S16LSB : SDL.AUDIO_S16MSB; - public static readonly int MIX_DEFAULT_CHANNELS = 2; - public static readonly byte MIX_MAX_VOLUME = 128; - - [Flags] - public enum MIX_InitFlags - { - MIX_INIT_FLAC = 0x00000001, - MIX_INIT_MOD = 0x00000002, - MIX_INIT_MP3 = 0x00000004, - MIX_INIT_OGG = 0x00000008, - MIX_INIT_FLUIDSYNTH = 0x00000010, - } - - public enum Mix_Fading - { - MIX_NO_FADING, - MIX_FADING_OUT, - MIX_FADING_IN - } - - public enum Mix_MusicType - { - MUS_NONE, - MUS_CMD, - MUS_WAV, - MUS_MOD, - MUS_MID, - MUS_OGG, - MUS_MP3, - MUS_MP3_MAD, - MUS_FLAC, - MUS_MODPLUG - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void MixFuncDelegate( - IntPtr udata, // void* - IntPtr stream, // Uint8* - int len - ); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Mix_EffectFunc_t( - int chan, - IntPtr stream, // void* - int len, - IntPtr udata // void* - ); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Mix_EffectDone_t( - int chan, - IntPtr udata // void* - ); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void MusicFinishedDelegate(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void ChannelFinishedDelegate(int channel); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate int SoundFontDelegate( - IntPtr a, // const char* - IntPtr b // void* - ); - - public static void SDL_MIXER_VERSION(out SDL.SDL_version X) - { - X.major = SDL_MIXER_MAJOR_VERSION; - X.minor = SDL_MIXER_MINOR_VERSION; - X.patch = SDL_MIXER_PATCHLEVEL; - } - - [DllImport(nativeLibName, EntryPoint = "MIX_Linked_Version", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr INTERNAL_MIX_Linked_Version(); - public static SDL.SDL_version MIX_Linked_Version() - { - SDL.SDL_version result; - IntPtr result_ptr = INTERNAL_MIX_Linked_Version(); - result = (SDL.SDL_version) Marshal.PtrToStructure( - result_ptr, - typeof(SDL.SDL_version) - ); - return result; - } - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_Init(MIX_InitFlags flags); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_Quit(); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_OpenAudio( - int frequency, - ushort format, - int channels, - int chunksize - ); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_AllocateChannels(int numchans); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_QuerySpec( - out int frequency, - out ushort format, - out int channels - ); - - /* src refers to an SDL_RWops*, IntPtr to a Mix_Chunk* */ - /* THIS IS A PUBLIC RWops FUNCTION! */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr Mix_LoadWAV_RW( - IntPtr src, - int freesrc - ); - - /* IntPtr refers to a Mix_Chunk* */ - /* This is an RWops macro in the C header. */ - public static IntPtr Mix_LoadWAV(string file) - { - IntPtr rwops = SDL.INTERNAL_SDL_RWFromFile(file, "rb"); - return Mix_LoadWAV_RW(rwops, 1); - } - - /* IntPtr refers to a Mix_Music* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr Mix_LoadMUS( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string file - ); - - /* IntPtr refers to a Mix_Chunk* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr Mix_QuickLoad_WAV( - [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)] - byte[] mem - ); - - /* IntPtr refers to a Mix_Chunk* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr Mix_QuickLoad_RAW( - [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 1)] - byte[] mem, - uint len - ); - - /* chunk refers to a Mix_Chunk* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_FreeChunk(IntPtr chunk); - - /* music refers to a Mix_Music* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_FreeMusic(IntPtr music); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_GetNumChunkDecoders(); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string Mix_GetChunkDecoder(int index); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_GetNumMusicDecoders(); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string Mix_GetMusicDecoder(int index); - - /* music refers to a Mix_Music* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Mix_MusicType Mix_GetMusicType(IntPtr music); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_SetPostMix( - MixFuncDelegate mix_func, - IntPtr arg // void* - ); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_HookMusic( - MixFuncDelegate mix_func, - IntPtr arg // void* - ); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_HookMusicFinished( - MusicFinishedDelegate music_finished - ); - - /* IntPtr refers to a void* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr Mix_GetMusicHookData(); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void Mix_ChannelFinished( - ChannelFinishedDelegate channel_finished - ); - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int Mix_RegisterEffect( - int chan, - Mix_EffectFu... [truncated message content] |
From: <ka...@us...> - 2014-08-03 00:09:15
|
Revision: 1433 http://sourceforge.net/p/agate/code/1433 Author: kanato Date: 2014-08-03 00:09:08 +0000 (Sun, 03 Aug 2014) Log Message: ----------- Fix line endings. Modified Paths: -------------- trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2.cs Modified: trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2.cs =================================================================== --- trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2.cs 2014-08-02 23:49:08 UTC (rev 1432) +++ trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2.cs 2014-08-03 00:09:08 UTC (rev 1433) @@ -1,5620 +1,5620 @@ -#region License -/* SDL2# - C# Wrapper for SDL2 - * - * Copyright (c) 2013-2014 Ethan Lee. - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in a - * product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source distribution. - * - * Ethan "flibitijibibo" Lee <fli...@fl...> - * - */ -#endregion - -#region Using Statements -using System; -using System.Runtime.InteropServices; +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2014 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee <fli...@fl...> + * + */ #endregion -namespace SDL2.ThirtyTwo -{ - /// <summary> - /// Entry point for all SDL-related (non-extension) types and methods - /// </summary> - public static class SDL - { - #region SDL2# Variables - - /// <summary> - /// Used by DllImport to load the native library. - /// </summary> - private const string nativeLibName = "lib64/SDL2.dll"; - - #endregion - - #region SDL_stdinc.h - - public static uint SDL_FOURCC(byte A, byte B, byte C, byte D) - { - return (uint) (A | (B << 8) | (C << 16) | (D << 24)); - } - - public enum SDL_bool - { - SDL_FALSE = 0, - SDL_TRUE = 1 - } - - #endregion - - #region SDL_rwops.h - - /* Note about SDL2# and Internal RWops: - * These functions are currently not supported for public use. - * They are only meant to be used internally in functions marked with - * the phrase "THIS IS AN RWops FUNCTION!" - */ - - /// <summary> - /// Use this function to create a new SDL_RWops structure for reading from and/or writing to a named file. - /// </summary> - /// <param name="file">a UTF-8 string representing the filename to open</param> - /// <param name="mode">an ASCII string representing the mode to be used for opening the file; see Remarks for details</param> - /// <returns>Returns a pointer to the SDL_RWops structure that is created, or NULL on failure; call SDL_GetError() for more information.</returns> - [DllImport(nativeLibName, EntryPoint = "SDL_RWFromFile", CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr INTERNAL_SDL_RWFromFile( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string file, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string mode - ); - - /* These are the public RWops functions. They should be used by - * functions marked with the phrase "THIS IS A PUBLIC RWops FUNCTION!" - */ - - /* IntPtr refers to an SDL_RWops */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_RWFromMem(byte[] mem, int size); - - #endregion - - #region SDL_main.h - - /// <summary> - /// Use this function to circumvent failure of SDL_Init() when not using SDL_main() as an entry point. - /// </summary> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_SetMainReady(); - - #endregion - - #region SDL.h - - public const uint SDL_INIT_TIMER = 0x00000001; - public const uint SDL_INIT_AUDIO = 0x00000010; - public const uint SDL_INIT_VIDEO = 0x00000020; - public const uint SDL_INIT_JOYSTICK = 0x00000200; - public const uint SDL_INIT_HAPTIC = 0x00001000; - public const uint SDL_INIT_GAMECONTROLLER = 0x00002000; - public const uint SDL_INIT_NOPARACHUTE = 0x00100000; - public const uint SDL_INIT_EVERYTHING = ( - SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | - SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | - SDL_INIT_GAMECONTROLLER - ); - - /// <summary> - /// Use this function to initialize the SDL library. - /// This must be called before using any other SDL function. - /// </summary> - /// <param name="flags">subsystem initialization flags; see Remarks for details</param> - /// <returns>Returns 0 on success or a negative error code on failure. - /// Call <see cref="SDL_GetError()"/> for more information.</returns> - /// <remarks>The Event Handling, File I/O, and Threading subsystems are initialized by default. - /// You must specifically initialize other subsystems if you use them in your application.</remarks> - /// <remarks>Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup signal handlers - /// for some commonly ignored fatal signals (like SIGSEGV). </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_Init(uint flags); - - /// <summary> - /// Use this function to initialize specific SDL subsystems. - /// </summary> - /// <param name="flags">any of the flags used by SDL_Init(); see Remarks for details</param> - /// <returns>Returns 0 on success or a negative error code on failure. - /// Call <see cref="SDL_GetError()"/> for more information.</returns> - /// <remarks>After SDL has been initialized with <see cref="SDL_Init()"/> you may initialize - /// uninitialized subsystems with <see cref="SDL_InitSubSystem()"/>.</remarks> - /// <remarks>If you want to initialize subsystems separately you would call <see cref="SDL_Init(0)"/> - /// followed by <see cref="SDL_InitSubSystem()"/> with the desired subsystem flag. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_InitSubSystem(uint flags); - - /// <summary> - /// Use this function to clean up all initialized subsystems. - /// You should call it upon all exit conditions. - /// </summary> - /// <remarks>You should call this function even if you have already shutdown each initialized - /// subsystem with <see cref="SDL_QuitSubSystem()"/>.</remarks> - /// <remarks>If you start a subsystem using a call to that subsystem's init function (for example - /// <see cref="SDL_VideoInit()"/>) instead of <see cref="SDL_Init()"/> or <see cref="SDL_InitSubSystem()"/>, - /// then you must use that subsystem's quit function (<see cref="SDL_VideoQuit()"/>) to shut it down - /// before calling <see cref="SDL_Quit()"/>.</remarks> - /// <remarks>You can use this function with atexit() to ensure that it is run when your application is - /// shutdown, but it is not wise to do this from a library or other dynamically loaded code. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_Quit(); - - /// <summary> - /// Use this function to shut down specific SDL subsystems. - /// </summary> - /// <param name="flags">any of the flags used by <see cref="SDL_Init()"/>; see Remarks for details</param> - /// <remarks>If you start a subsystem using a call to that subsystem's init function (for example - /// <see cref="SDL_VideoInit()"/>) instead of <see cref="SDL_Init()"/> or <see cref="SDL_InitSubSystem()"/>, - /// then you must use that subsystem's quit function (<see cref="SDL_VideoQuit()"/>) to shut it down - /// before calling <see cref="SDL_Quit()"/>.</remarks> - /// <remarks>You can use this function with atexit() to en - /// <remarks>You still need to call <see cref="SDL_Quit()"/> even if you close all open subsystems with SDL_QuitSubSystem(). </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_QuitSubSystem(uint flags); - - /// <summary> - /// Use this function to return a mask of the specified subsystems which have previously been initialized. - /// </summary> - /// <param name="flags">any of the flags used by <see cref="SDL_Init()"/>; see Remarks for details</param> - /// <returns>If flags is 0 it returns a mask of all initialized subsystems, otherwise it returns the - /// initialization status of the specified subsystems. The return value does not include SDL_INIT_NOPARACHUTE.</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint SDL_WasInit(uint flags); - - #endregion - - #region SDL_platform.h - - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetPlatform(); - - #endregion - - #region SDL_hints.h - - public const string SDL_HINT_FRAMEBUFFER_ACCELERATION = - "SDL_FRAMEBUFFER_ACCELERATION"; - public const string SDL_HINT_RENDER_DRIVER = - "SDL_RENDER_DRIVER"; - public const string SDL_HINT_RENDER_OPENGL_SHADERS = - "SDL_RENDER_OPENGL_SHADERS"; - public const string SDL_HINT_RENDER_DIRECT3D_THREADSAFE = - "SDL_RENDER_DIRECT3D_THREADSAFE"; - public const string SDL_HINT_RENDER_VSYNC = - "SDL_RENDER_VSYNC"; - public const string SDL_HINT_VIDEO_X11_XVIDMODE = - "SDL_VIDEO_X11_XVIDMODE"; - public const string SDL_HINT_VIDEO_X11_XINERAMA = - "SDL_VIDEO_X11_XINERAMA"; - public const string SDL_HINT_VIDEO_X11_XRANDR = - "SDL_VIDEO_X11_XRANDR"; - public const string SDL_HINT_GRAB_KEYBOARD = - "SDL_GRAB_KEYBOARD"; - public const string SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS = - "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"; - public const string SDL_HINT_IDLE_TIMER_DISABLED = - "SDL_IOS_IDLE_TIMER_DISABLED"; - public const string SDL_HINT_ORIENTATIONS = - "SDL_IOS_ORIENTATIONS"; - public const string SDL_HINT_XINPUT_ENABLED = - "SDL_XINPUT_ENABLED"; - public const string SDL_HINT_GAMECONTROLLERCONFIG = - "SDL_GAMECONTROLLERCONFIG"; - public const string SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS = - "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"; - public const string SDL_HINT_ALLOW_TOPMOST = - "SDL_ALLOW_TOPMOST"; - public const string SDL_HINT_TIMER_RESOLUTION = - "SDL_TIMER_RESOLUTION"; - public const string SDL_HINT_RENDER_SCALE_QUALITY = - "SDL_RENDER_SCALE_QUALITY"; - - /* Only available in SDL 2.0.1 or higher */ - public const string SDL_HINT_VIDEO_HIGHDPI_DISABLED = - "SDL_VIDEO_HIGHDPI_DISABLED"; - - /* Only available in SDL 2.0.2 or higher */ - public const string SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK = - "SDL_CTRL_CLICK_EMULATE_RIGHT_CLICK"; - public const string SDL_HINT_VIDEO_WIN_D3DCOMPILER = - "SDL_VIDEO_WIN_D3DCOMPILER"; - public const string SDL_HINT_MOUSE_RELATIVE_MODE_WARP = - "SDL_MOUSE_RELATIVE_MODE_WARP"; - public const string SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT = - "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"; - public const string SDL_HINT_VIDEO_ALLOW_SCREENSAVER = - "SDL_VIDEO_ALLOW_SCREENSAVER"; - public const string SDL_HINT_ACCELEROMETER_AS_JOYSTICK = - "SDL_ACCELEROMETER_AS_JOYSTICK"; - public const string SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES = - "SDL_VIDEO_MAC_FULLSCREEN_SPACES"; - - public enum SDL_HintPriority - { - SDL_HINT_DEFAULT, - SDL_HINT_NORMAL, - SDL_HINT_OVERRIDE - } - - /// <summary> - /// Use this function to clear all hints. - /// </summary> - /// <remarks>This function is automatically called during <see cref="SDL_Quit()"/>. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_ClearHints(); - - /// <summary> - /// Use this function to get the value of a hint. - /// </summary> - /// <param name="name">the hint to query; see the list of hints on - /// <a href="http://wiki.libsdl.org/moin.cgi/CategoryHints#Hints">CategoryHints</a> for details</param> - /// <returns>Returns the string value of a hint or NULL if the hint isn't set.</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetHint( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name - ); - - /// <summary> - /// Use this function to set a hint with normal priority. - /// </summary> - /// <param name="name">the hint to query; see the list of hints on - /// <a href="http://wiki.libsdl.org/moin.cgi/CategoryHints#Hints">CategoryHints</a> for details</param> - /// <param name="value">the value of the hint variable</param> - /// <returns>Returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.</returns> - /// <remarks>Hints will not be set if there is an existing override hint or environment - /// variable that takes precedence. You can use <see cref="SDL_SetHintWithPriority()"/> to set the hint with - /// override priority instead.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_bool SDL_SetHint( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string value - ); - - /// <summary> - /// Use this function to set a hint with a specific priority. - /// </summary> - /// <param name="name">the hint to query; see the list of hints on - /// <a href="http://wiki.libsdl.org/moin.cgi/CategoryHints#Hints">CategoryHints</a> for details</param> - /// <param name="value">the value of the hint variable</param> - /// <param name="priority">the <see cref="SDL_HintPriority"/> level for the hint</param> - /// <returns>Returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.</returns> - /// <remarks>The priority controls the behavior when setting a hint that already has a value. - /// Hints will replace existing hints of their priority and lower. Environment variables are - /// considered to have override priority. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_bool SDL_SetHintWithPriority( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string value, - SDL_HintPriority priority - ); - - #endregion - - #region SDL_error.h - - /// <summary> - /// Use this function to clear any previous error message. - /// </summary> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_ClearError(); - - /// <summary> - /// Use this function to retrieve a message about the last error that occurred. - /// </summary> - /// <returns>Returns a message with information about the specific error that occurred, - /// or an empty string if there hasn't been an error since the last call to <see cref="SDL_ClearError()"/>. - /// Without calling <see cref="SDL_ClearError()"/>, the message is only applicable when an SDL function - /// has signaled an error. You must check the return values of SDL function calls to determine - /// when to appropriately call <see cref="SDL_GetError()"/>. - /// This string is statically allocated and must not be freed by the application.</returns> - /// <remarks>It is possible for multiple errors to occur before calling SDL_GetError(). Only the last error is returned. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetError(); - - /// <summary> - /// Use this function to set the SDL error string. - /// </summary> - /// <param name="fmt">a printf() style message format string </param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>Calling this function will replace any previous error message that was set.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_SetError( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - #endregion - - #region SDL_log.h - - /* Begin nameless enum SDL_LOG_CATEGORY */ - public const int SDL_LOG_CATEGORY_APPLICATION = 0; - public const int SDL_LOG_CATEGORY_ERROR = 1; - public const int SDL_LOG_CATEGORY_ASSERT = 2; - public const int SDL_LOG_CATEGORY_SYSTEM = 3; - public const int SDL_LOG_CATEGORY_AUDIO = 4; - public const int SDL_LOG_CATEGORY_VIDEO = 5; - public const int SDL_LOG_CATEGORY_RENDER = 6; - public const int SDL_LOG_CATEGORY_INPUT = 7; - public const int SDL_LOG_CATEGORY_TEST = 8; - - /* Reserved for future SDL library use */ - public const int SDL_LOG_CATEGORY_RESERVED1 = 9; - public const int SDL_LOG_CATEGORY_RESERVED2 = 10; - public const int SDL_LOG_CATEGORY_RESERVED3 = 11; - public const int SDL_LOG_CATEGORY_RESERVED4 = 12; - public const int SDL_LOG_CATEGORY_RESERVED5 = 13; - public const int SDL_LOG_CATEGORY_RESERVED6 = 14; - public const int SDL_LOG_CATEGORY_RESERVED7 = 15; - public const int SDL_LOG_CATEGORY_RESERVED8 = 16; - public const int SDL_LOG_CATEGORY_RESERVED9 = 17; - public const int SDL_LOG_CATEGORY_RESERVED10 = 18; - - /* Beyond this point is reserved for application use, e.g. - enum { - LOG_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, - LOG_CATEGORY_AWESOME2, - LOG_CATEGORY_AWESOME3, - ... - }; - */ - public const int SDL_LOG_CATEGORY_CUSTOM = 19; - /* End nameless enum SDL_LOG_CATEGORY */ - - /// <summary> - /// An enumeration of the predefined log priorities. - /// </summary> - public enum SDL_LogPriority - { - SDL_LOG_PRIORITY_VERBOSE = 1, - SDL_LOG_PRIORITY_DEBUG, - SDL_LOG_PRIORITY_INFO, - SDL_LOG_PRIORITY_WARN, - SDL_LOG_PRIORITY_ERROR, - SDL_LOG_PRIORITY_CRITICAL, - SDL_NUM_LOG_PRIORITIES - } - - /// <summary> - /// Used as a callback for <see cref="SDL_LogGetOutputFunction()"/> and <see cref="SDL_LogSetOutputFunction()"/> - /// </summary> - /// <param name="userdata">what was passed as userdata to <see cref="SDL_LogSetOutputFunction()"/></param> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="priority">the priority of the message; see Remarks for details</param> - /// <param name="message">the message being output</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void SDL_LogOutputFunction( - IntPtr userdata, // void* - int category, - SDL_LogPriority priority, - IntPtr message // const char* - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO. - /// </summary> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_Log( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_VERBOSE. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogVerbose( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_DEBUG. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogDebug( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_INFO. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogInfo( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_WARN. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogWarn( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_ERROR. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogError( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with SDL_LOG_PRIORITY_CRITICAL. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogCritical( - int category, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with the specified category and priority. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="priority">the priority of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogMessage( - int category, - SDL_LogPriority priority, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to log a message with the specified category and priority. - /// This version of <see cref="SDL_LogMessage"/> uses a stdarg variadic argument list. - /// </summary> - /// <param name="category">the category of the message; see Remarks for details</param> - /// <param name="priority">the priority of the message; see Remarks for details</param> - /// <param name="fmt">a printf() style message format string</param> - /// <param name="...">additional parameters matching % tokens in the fmt string, if any</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogMessageV( - int category, - SDL_LogPriority priority, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string fmt, - __arglist - ); - - /// <summary> - /// Use this function to get the priority of a particular log category. - /// </summary> - /// <param name="category">the category to query; see Remarks for details</param> - /// <returns>Returns the <see cref="SDL_LogPriority"/> for the requested category; see Remarks for details. </returns> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The returned priority will be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_LogPriority SDL_LogGetPriority( - int category - ); - - /// <summary> - /// Use this function to set the priority of a particular log category. - /// </summary> - /// <param name="category">the category to query; see Remarks for details</param> - /// <param name="priority">the <see cref="SDL_LogPriority"/> of the message; see Remarks for details</param> - /// <remarks>The category can be one of SDL_LOG_CATEGORY*</remarks> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogSetPriority( - int category, - SDL_LogPriority priority - ); - - /// <summary> - /// Use this function to set the priority of all log categories. - /// </summary> - /// <param name="priority">the <see cref="SDL_LogPriority"/> of the message; see Remarks for details</param> - /// <remarks>The priority can be one of SDL_LOG_PRIORITY*</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogSetAllPriority( - SDL_LogPriority priority - ); - - /// <summary> - /// Use this function to reset all priorities to default. - /// </summary> - /// <remarks>This is called in <see cref="SDL_Quit()"/>. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogResetPriorities(); - - /// <summary> - /// Use this function to get the current log output function. - /// </summary> - /// <param name="callback">a pointer filled in with the current log callback; see Remarks for details</param> - /// <param name="userdata">a pointer filled in with the pointer that is passed to callback (refers to void*)</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogGetOutputFunction( - out SDL_LogOutputFunction callback, - out IntPtr userdata - ); - - /* userdata refers to a void* */ - /// <summary> - /// Use this function to replace the default log output function with one of your own. - /// </summary> - /// <param name="callback">the function to call instead of the default; see Remarks for details</param> - /// <param name="userdata">a pointer that is passed to callback (refers to void*)</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_LogSetOutputFunction( - SDL_LogOutputFunction callback, - IntPtr userdata - ); - - #endregion - - #region SDL_messagebox.h - - [Flags] - public enum SDL_MessageBoxFlags : uint - { - SDL_MESSAGEBOX_ERROR = 0x00000010, - SDL_MESSAGEBOX_WARNING = 0x00000020, - SDL_MESSAGEBOX_INFORMATION = 0x00000040 - } - - [Flags] - public enum SDL_MessageBoxButtonFlags : uint - { - SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, - SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 - } - - [StructLayout(LayoutKind.Sequential)] - private struct INTERNAL_SDL_MessageBoxButtonData - { - public SDL_MessageBoxButtonFlags flags; - public int buttonid; - public IntPtr text; /* The UTF-8 button text */ - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxButtonData - { - public SDL_MessageBoxButtonFlags flags; - public int buttonid; - public string text; /* The UTF-8 button text */ - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxColor - { - public byte r, g, b; - } - - public enum SDL_MessageBoxColorType - { - SDL_MESSAGEBOX_COLOR_BACKGROUND, - SDL_MESSAGEBOX_COLOR_TEXT, - SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, - SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, - SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, - SDL_MESSAGEBOX_COLOR_MAX - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxColorScheme - { - [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)SDL_MessageBoxColorType.SDL_MESSAGEBOX_COLOR_MAX)] - public SDL_MessageBoxColor[] colors; - } - - [StructLayout(LayoutKind.Sequential)] - private struct INTERNAL_SDL_MessageBoxData - { - public SDL_MessageBoxFlags flags; - public IntPtr window; /* Parent window, can be NULL */ - public IntPtr title; /* UTF-8 title */ - public IntPtr message; /* UTF-8 message text */ - public int numbuttons; - public IntPtr buttons; - public IntPtr colorScheme; /* Can be NULL to use system settings */ - } - - [StructLayout(LayoutKind.Sequential)] - public struct SDL_MessageBoxData - { - public SDL_MessageBoxFlags flags; - public IntPtr window; /* Parent window, can be NULL */ - public string title; /* UTF-8 title */ - public string message; /* UTF-8 message text */ - public int numbuttons; - public SDL_MessageBoxButtonData[] buttons; - public SDL_MessageBoxColorScheme? colorScheme; /* Can be NULL to use system settings */ - } - - /// <summary> - /// - /// </summary> - /// <param name="messageboxdata"></param> - /// <param name="buttonid"></param> - /// <returns></returns> - [DllImport(nativeLibName, EntryPoint = "SDL_ShowMessageBox", CallingConvention = CallingConvention.Cdecl)] - private static extern int INTERNAL_SDL_ShowMessageBox([In()] ref INTERNAL_SDL_MessageBoxData messageboxdata, out int buttonid); - - /// <summary> - /// - /// </summary> - /// <param name="messageboxdata"></param> - /// <param name="buttonid"></param> - /// <returns></returns> - public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid) - { - var utf8 = LPUtf8StrMarshaler.GetInstance(null); - - var data = new INTERNAL_SDL_MessageBoxData() - { - flags = messageboxdata.flags, - window = messageboxdata.window, - title = utf8.MarshalManagedToNative(messageboxdata.title), - message = utf8.MarshalManagedToNative(messageboxdata.message), - numbuttons = messageboxdata.numbuttons, - }; - - var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons]; - for (int i = 0; i < messageboxdata.numbuttons; i++) - { - buttons[i] = new INTERNAL_SDL_MessageBoxButtonData() - { - flags = messageboxdata.buttons[i].flags, - buttonid = messageboxdata.buttons[i].buttonid, - text = utf8.MarshalManagedToNative(messageboxdata.buttons[i].text), - }; - } - - if (messageboxdata.colorScheme != null) - { - data.colorScheme = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDL_MessageBoxColorScheme))); - Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false); - } - - int result; - fixed (INTERNAL_SDL_MessageBoxButtonData* buttonsPtr = &buttons[0]) - { - data.buttons = (IntPtr)buttonsPtr; - result = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid); - } - - Marshal.FreeHGlobal(data.colorScheme); - for (int i = 0; i < messageboxdata.numbuttons; i++) - { - utf8.CleanUpNativeData(buttons[i].text); - } - utf8.CleanUpNativeData(data.message); - utf8.CleanUpNativeData(data.title); - - return result; - } - - /// <summary> - /// Use this function to display a simple message box. - /// </summary> - /// <param name="flags">An <see cref="SDL_MessageBoxFlag"/>; see Remarks for details;</param> - /// <param name="title">UTF-8 title text</param> - /// <param name="message">UTF-8 message text</param> - /// <param name="window">the parent window, or NULL for no parent (refers to a <see cref="SDL_Window"/></param> - /// <returns>0 on success or a negative error code on failure; call SDL_GetError() for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_ShowSimpleMessageBox( - SDL_MessageBoxFlags flags, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string title, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string message, - IntPtr window - ); - - #endregion - - #region SDL_version.h, SDL_revision.h - - /* Similar to the headers, this is the version we're expecting to be - * running with. You will likely want to check this somewhere in your - * program! - */ - public const int SDL_MAJOR_VERSION = 2; - public const int SDL_MINOR_VERSION = 0; - public const int SDL_PATCHLEVEL = 3; - - public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM( - SDL_MAJOR_VERSION, - SDL_MINOR_VERSION, - SDL_PATCHLEVEL - ); - - /// <summary> - /// A structure that contains information about the version of SDL in use. - /// </summary> - /// <remarks>Represents the library's version as three levels: </remarks> - /// <remarks>major revision (increments with massive changes, additions, and enhancements) </remarks> - /// <remarks>minor revision (increments with backwards-compatible changes to the major revision), and </remarks> - /// <remarks>patchlevel (increments with fixes to the minor revision)</remarks> - /// <remarks><see cref="SDL_VERSION"/> can be used to populate this structure with information</remarks> - [StructLayout(LayoutKind.Sequential)] - public struct SDL_version - { - public byte major; - public byte minor; - public byte patch; - } - - /// <summary> - /// Use this macro to determine the SDL version your program was compiled against. - /// </summary> - /// <param name="x">an <see cref="SDL_version"/> structure to initialize</param> - public static void SDL_VERSION(out SDL_version x) - { - x.major = SDL_MAJOR_VERSION; - x.minor = SDL_MINOR_VERSION; - x.patch = SDL_PATCHLEVEL; - } - - /// <summary> - /// Use this macro to convert separate version components into a single numeric value. - /// </summary> - /// <param name="X">major version; reported in thousands place</param> - /// <param name="Y">minor version; reported in hundreds place</param> - /// <param name="Z">update version (patchlevel); reported in tens and ones places</param> - /// <returns></returns> - /// <remarks>This assumes that there will never be more than 100 patchlevels.</remarks> - /// <remarks>Example: SDL_VERSIONNUM(1,2,3) -> (1203)</remarks> - public static int SDL_VERSIONNUM(int X, int Y, int Z) - { - return (X * 1000) + (Y * 100) + Z; - } - - /// <summary> - /// Use this macro to determine whether the SDL version compiled against is at least as new as the specified version. - /// </summary> - /// <param name="X">major version</param> - /// <param name="Y">minor version</param> - /// <param name="Z">update version (patchlevel)</param> - /// <returns>This macro will evaluate to true if compiled with SDL version at least X.Y.Z. </returns> - public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z) - { - return (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)); - } - - /// <summary> - /// Use this function to get the version of SDL that is linked against your program. - /// </summary> - /// <param name="ver">the <see cref="SDL_version"/> structure that contains the version information</param> - /// <remarks>This function may be called safely at any time, even before SDL_Init(). </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - private static extern void SDL_GetVersion(out SDL_version ver); - - /// <summary> - /// Use this function to get the code revision of SDL that is linked against your program. - /// </summary> - /// <returns>Returns an arbitrary string, uniquely identifying the exact revision - /// of the SDL library in use. </returns> - /// <remarks>The revision is a string including sequential revision number that is - /// incremented with each commit, and a hash of the last code change.</remarks> - /// <remarks>Example: hg-5344:94189aa89b54</remarks> - /// <remarks>This value is the revision of the code you are linked with and may be - /// different from the code you are compiling with, which is found in the constant SDL_REVISION.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetRevision(); - - /// <summary> - /// Use this function to get the revision number of SDL that is linked against your program. - /// </summary> - /// <returns>Returns a number uniquely identifying the exact revision of the SDL library in use.</returns> - /// <remarks>This is an incrementing number based on commits to hg.libsdl.org.</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetRevisionNumber(); - - #endregion - - #region SDL_video.h - - /* Actually, this is from SDL_blendmode.h */ - /// <summary> - /// An enumeration of blend modes used in SDL_RenderCopy() and drawing operations. - /// </summary> - [Flags] - public enum SDL_BlendMode - { - SDL_BLENDMODE_NONE = 0x00000000, - SDL_BLENDMODE_BLEND = 0x00000001, - SDL_BLENDMODE_ADD = 0x00000002, - SDL_BLENDMODE_MOD = 0x00000004 - } - - /// <summary> - /// An enumeration of OpenGL configuration attributes. - /// </summary> - public enum SDL_GLattr - { - SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, - SDL_GL_RETAINED_BACKING, - SDL_GL_CONTEXT_MAJOR_VERSION, - SDL_GL_CONTEXT_MINOR_VERSION, - SDL_GL_CONTEXT_EGL, - SDL_GL_CONTEXT_FLAGS, - SDL_GL_CONTEXT_PROFILE_MASK, - SDL_GL_SHARE_WITH_CURRENT_CONTEXT, - SDL_GL_FRAMEBUFFER_SRGB_CAPABLE - } - - /// <summary> - /// An enumeration of OpenGL profiles. - /// </summary> - [Flags] - public enum SDL_GLprofile - { - SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, - SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, - SDL_GL_CONTEXT_PROFILE_ES = 0x0004 - } - - /// <summary> - /// This enumeration is used in conjunction with SDL_GL_SetAttribute - /// and SDL_GL_CONTEXT_FLAGS. Multiple flags can be OR'd together. - /// </summary> - [Flags] - public enum SDL_GLcontext - { - SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, - SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, - SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, - SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 - } - - /// <summary> - /// An enumeration of window events. - /// </summary> - public enum SDL_WindowEventID : byte - { - SDL_WINDOWEVENT_NONE, - SDL_WINDOWEVENT_SHOWN, - SDL_WINDOWEVENT_HIDDEN, - SDL_WINDOWEVENT_EXPOSED, - SDL_WINDOWEVENT_MOVED, - SDL_WINDOWEVENT_RESIZED, - SDL_WINDOWEVENT_SIZE_CHANGED, - SDL_WINDOWEVENT_MINIMIZED, - SDL_WINDOWEVENT_MAXIMIZED, - SDL_WINDOWEVENT_RESTORED, - SDL_WINDOWEVENT_ENTER, - SDL_WINDOWEVENT_LEAVE, - SDL_WINDOWEVENT_FOCUS_GAINED, - SDL_WINDOWEVENT_FOCUS_LOST, - SDL_WINDOWEVENT_CLOSE, - } - - /// <summary> - /// An enumeration of window states. - /// </summary> - [Flags] - public enum SDL_WindowFlags - { - SDL_WINDOW_FULLSCREEN = 0x00000001, - SDL_WINDOW_OPENGL = 0x00000002, - SDL_WINDOW_SHOWN = 0x00000004, - SDL_WINDOW_HIDDEN = 0x00000008, - SDL_WINDOW_BORDERLESS = 0x00000010, - SDL_WINDOW_RESIZABLE = 0x00000020, - SDL_WINDOW_MINIMIZED = 0x00000040, - SDL_WINDOW_MAXIMIZED = 0x00000080, - SDL_WINDOW_INPUT_GRABBED = 0x00000100, - SDL_WINDOW_INPUT_FOCUS = 0x00000200, - SDL_WINDOW_MOUSE_FOCUS = 0x00000400, - SDL_WINDOW_FULLSCREEN_DESKTOP = - (SDL_WINDOW_FULLSCREEN | 0x00001000), - SDL_WINDOW_FOREIGN = 0x00000800, - SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /* Only available in 2.0.1 */ - } - - public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; - public const int SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000; - public const int SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000; - public const int SDL_WINDOWPOS_CENTERED = 0x2FFF0000; - - public static int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int X) - { - return (SDL_WINDOWPOS_UNDEFINED_MASK | X); - } - - public static bool SDL_WINDOWPOS_ISUNDEFINED(int X) - { - return (X & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK; - } - - public static int SDL_WINDOWPOS_CENTERED_DISPLAY(int X) - { - return (SDL_WINDOWPOS_CENTERED_MASK | X); - } - - public static bool SDL_WINDOWPOS_ISCENTERED(int X) - { - return (X & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK; - } - - /// <summary> - /// A structure that describes a display mode. - /// </summary> - [StructLayout(LayoutKind.Sequential)] - public struct SDL_DisplayMode - { - public uint format; - public int w; - public int h; - public int refresh_rate; - public IntPtr driverdata; // void* - } - - /// <summary> - /// Use this function to create a window with the specified position, dimensions, and flags. - /// </summary> - /// <param name="title">the title of the window, in UTF-8 encoding</param> - /// <param name="x">the x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED</param> - /// <param name="y">the y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED</param> - /// <param name="w">the width of the window</param> - /// <param name="h">the height of the window</param> - /// <param name="flags">0, or one or more <see cref="SDL_WindowFlags"/> OR'd together; - /// see Remarks for details</param> - /// <returns>Returns the window that was created or NULL on failure; call <see cref="SDL_GetError()"/> - /// for more information. (refers to an <see cref="SDL_Window"/>)</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_CreateWindow( - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string title, - int x, - int y, - int w, - int h, - SDL_WindowFlags flags - ); - - /// <summary> - /// Use this function to create a window and default renderer. - /// </summary> - /// <param name="width">The width of the window</param> - /// <param name="height">The height of the window</param> - /// <param name="window_flags">The flags used to create the window (see <see cref="SDL_CreateWindow()"/>)</param> - /// <param name="window">A pointer filled with the window, or NULL on error (<see cref="SDL_Window*"/>)</param> - /// <param name="renderer">A pointer filled with the renderer, or NULL on error <see cref="(SDL_Renderer*)"/></param> - /// <returns>Returns 0 on success, or -1 on error; call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_CreateWindowAndRenderer( - int width, - int height, - SDL_WindowFlags window_flags, - out IntPtr window, - out IntPtr renderer - ); - - /// <summary> - /// Use this function to create an SDL window from an existing native window. - /// </summary> - /// <param name="data">a pointer to driver-dependent window creation data, typically your native window cast to a void*</param> - /// <returns>Returns the window (<see cref="SDL_Window"/>) that was created or NULL on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_CreateWindowFrom(IntPtr data); - - /// <summary> - /// Use this function to destroy a window. - /// </summary> - /// <param name="window">the window to destroy (<see cref="SDL_Window"/>)</param> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_DestroyWindow(IntPtr window); - - /// <summary> - /// Use this function to prevent the screen from being blanked by a screen saver. - /// </summary> - /// <remarks>If you disable the screensaver, it is automatically re-enabled when SDL quits. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_DisableScreenSaver(); - - /// <summary> - /// Use this function to allow the screen to be blanked by a screen saver. - /// </summary> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_EnableScreenSaver(); - - /* IntPtr refers to an SDL_DisplayMode. Just use closest. */ - /// <summary> - /// Use this function to get the closest match to the requested display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure containing the desired display mode </param> - /// <param name="closest">an <see cref="SDL_DisplayMode"/> structure filled in with - /// the closest match of the available display modes </param> - /// <returns>Returns the passed in value closest or NULL if no matching video mode was available; - /// (refers to a <see cref="SDL_DisplayMode"/>) - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>The available display modes are scanned and closest is filled in with the closest mode - /// matching the requested mode and returned. The mode format and refresh rate default to the desktop - /// mode if they are set to 0. The modes are scanned with size being first priority, format being - /// second priority, and finally checking the refresh rate. If all the available modes are too small, - /// then NULL is returned. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_GetClosestDisplayMode( - int displayIndex, - ref SDL_DisplayMode mode, - out SDL_DisplayMode closest - ); - - /// <summary> - /// Use this function to get information about the current display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the current display mode</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>There's a difference between this function and <see cref="SDL_GetDesktopDisplayMode"/> when SDL - /// runs fullscreen and has changed the resolution. In that case this function will return the - /// current display mode, and not the previous native display mode. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetCurrentDisplayMode( - int displayIndex, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to return the name of the currently initialized video driver. - /// </summary> - /// <returns>Returns the name of the current video driver or NULL if no driver has been initialized. </returns> - /// <remarks>There's a difference between this function and <see cref="SDL_GetCurrentDisplayMode"/> when SDL - /// runs fullscreen and has changed the resolution. In that case this function will return the - /// previous native display mode, and not the current display mode. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetCurrentVideoDriver(); - - /// <summary> - /// Use this function to get information about the desktop display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the current display mode</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>There's a difference between this function and <see cref="SDL_GetCurrentDisplayMode"/> when SDL - /// runs fullscreen and has changed the resolution. In that case this function will return the - /// previous native display mode, and not the current display mode. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetDesktopDisplayMode( - int displayIndex, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to get the desktop area represented by a display, with the primary display located at 0,0. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="rect">the <see cref="SDL_Rect"/> structure filled in with the display bounds</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetDisplayBounds( - int displayIndex, - out SDL_Rect rect - ); - - /// <summary> - /// Use this function to get information about a specific display mode. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <param name="modeIndex">the index of the display mode to query</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the mode at modeIndex</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - /// <remarks>The display modes are sorted in this priority: - /// <remarks>bits per pixel -> more colors to fewer colors</remarks> - /// <remarks>width -> largest to smallest</remarks> - /// <remarks>height -> largest to smallest</remarks> - /// <remarks>refresh rate -> highest to lowest</remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetDisplayMode( - int displayIndex, - int modeIndex, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to return the number of available display modes. - /// </summary> - /// <param name="displayIndex">the index of the display to query</param> - /// <returns>Returns a number >= 1 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetNumDisplayModes( - int displayIndex - ); - - /// <summary> - /// Use this function to return the number of available video displays. - /// </summary> - /// <returns>Returns a number >= 1 or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetNumVideoDisplays(); - - /// <summary> - /// Use this function to get the number of video drivers compiled into SDL. - /// </summary> - /// <returns>Returns a number >= 1 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetNumVideoDrivers(); - - /// <summary> - /// Use this function to get the name of a built in video driver. - /// </summary> - /// <param name="index">the index of a video driver</param> - /// <returns>Returns the name of the video driver with the given index. </returns> - /// <remarks>The video drivers are presented in the order in which they are normally checked during initialization. </remarks> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler), MarshalCookie = LPUtf8StrMarshaler.LeaveAllocated)] - public static extern string SDL_GetVideoDriver( - int index - ); - - /// <summary> - /// Use this function to get the brightness (gamma correction) for a window. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <returns>Returns the brightness for the window where 0.0 is completely dark and 1.0 is normal brightness. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern float SDL_GetWindowBrightness( - IntPtr window - ); - - /// <summary> - /// Use this function to retrieve the data pointer associated with a window. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <param name="name">the name of the pointer</param> - /// <returns>Returns the value associated with name. (void*)</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_GetWindowData( - IntPtr window, - [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] - string name - ); - - /// <summary> - /// Use this function to get the index of the display associated with a window. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <returns>Returns the index of the display containing the center of the window - /// on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetWindowDisplayIndex( - IntPtr window - ); - - /// <summary> - /// Use this function to fill in information about the display mode to use when a window is visible at fullscreen. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <param name="mode">an <see cref="SDL_DisplayMode"/> structure filled in with the fullscreen display mode</param> - /// <returns>Returns 0 on success or a negative error code on failure; - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetWindowDisplayMode( - IntPtr window, - out SDL_DisplayMode mode - ); - - /// <summary> - /// Use this function to get the window flags. - /// </summary> - /// <param name="window">the window to query (<see cref="SDL_Window"/>)</param> - /// <returns>Returns a mask of the <see cref="SDL_WindowFlags"/> associated with window; see Remarks for details.</returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint SDL_GetWindowFlags(IntPtr window); - - /// <summary> - /// Use this function to get a window from a stored ID. - /// </summary> - /// <param name="id">the ID of the window</param> - /// <returns>Returns the window associated with id or NULL if it doesn't exist (<see cref="SDL_Window"/>); - /// call <see cref="SDL_GetError()"/> for more information. </returns> - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_GetWindowFromID(uint id); - - /* window refers to an SDL_Window* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_GetWindowGammaRamp( - IntPtr window, - [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] - ushort[] red, - [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] - ushort[] green, - [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] - ushort[] blue - ); - - /* window refers to an SDL_Window* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern SDL_bool SDL_GetWindowGrab(IntPtr window); - - /* window refers to an SDL_Window* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint SDL_GetWindowID(IntPtr window); - - /* window refers to an SDL_Window* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern... [truncated message content] |
From: <ka...@us...> - 2014-08-02 23:49:17
|
Revision: 1432 http://sourceforge.net/p/agate/code/1432 Author: kanato Date: 2014-08-02 23:49:08 +0000 (Sat, 02 Aug 2014) Log Message: ----------- Initial setup of SDL in new AgateLib architecture. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib/ApplicationModels/ModelParameters.cs trunk/AgateLib/Core.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/Drivers/IPlatformFactory.cs trunk/AgateLib/Resources/AgateResourceCollection.cs trunk/AgateLib/Resources/ImageResource.cs trunk/AgateLib-Everything.sln trunk/AgateLib.GL/Properties/AssemblyInfo.cs trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/AgateLib.Platform.WindowsForms/Configuration.cs trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabase.cs trunk/AgateLib.Platform.WindowsForms/Data/AgateTableDictionary.cs trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs trunk/AgateLib.Platform.WindowsForms/Factories/SdlFactory.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileProviderList.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileSystemProvider.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/TgzFileProvider.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/ZipFileProvider.cs trunk/AgateLib.SDL/Audio/SDL_Audio.cs trunk/AgateLib.SDL/Audio/SDL_Music.cs trunk/AgateLib.SDL/Audio/SDL_SoundBuffer.cs trunk/AgateLib.SDL/Audio/SDL_SoundBufferSession.cs trunk/AgateLib.SDL/Input/SDL_Input.cs Added Paths: ----------- trunk/AgateLib/IO/FileProvider.cs trunk/AgateLib/IO/IReadFileProvider.cs trunk/AgateLib/IO/IReadWriteFileProvider.cs trunk/AgateLib/IO/IWriteFileProvider.cs trunk/AgateLib.SDL/ trunk/AgateLib.SDL/AgateLib.SDL.csproj trunk/AgateLib.SDL/AgateLib.SDL.dll.config trunk/AgateLib.SDL/Audio/ trunk/AgateLib.SDL/Input/ trunk/AgateLib.SDL/Properties/ trunk/AgateLib.SDL/Properties/AssemblyInfo.cs trunk/AgateLib.SDL/Sdl2/ trunk/AgateLib.SDL/Sdl2/ISDL.cs trunk/AgateLib.SDL/Sdl2/ISDLMixer.cs trunk/AgateLib.SDL/Sdl2/SDL32.cs trunk/AgateLib.SDL/Sdl2/SDL64.cs trunk/AgateLib.SDL/Sdl2/SDLConstants.cs trunk/AgateLib.SDL/Sdl2/SdlFactory.cs trunk/AgateLib.SDL/Sdl2/SixtyFour/ trunk/AgateLib.SDL/Sdl2/SixtyFour/LPUtf8StrMarshaler.cs trunk/AgateLib.SDL/Sdl2/SixtyFour/SDL2.cs trunk/AgateLib.SDL/Sdl2/SixtyFour/SDL2_image.cs trunk/AgateLib.SDL/Sdl2/SixtyFour/SDL2_mixer.cs trunk/AgateLib.SDL/Sdl2/SixtyFour/SDL2_ttf.cs trunk/AgateLib.SDL/Sdl2/ThirtyTwo/ trunk/AgateLib.SDL/Sdl2/ThirtyTwo/LPUtf8StrMarshaler.cs trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2.cs trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2_image.cs trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2_mixer.cs trunk/AgateLib.SDL/Sdl2/ThirtyTwo/SDL2_ttf.cs trunk/AgateLib.SDL/lib32/ trunk/AgateLib.SDL/lib32/LICENSE.FLAC.txt trunk/AgateLib.SDL/lib32/LICENSE.mikmod.txt trunk/AgateLib.SDL/lib32/LICENSE.modplug.txt trunk/AgateLib.SDL/lib32/LICENSE.ogg-vorbis.txt trunk/AgateLib.SDL/lib32/LICENSE.smpeg.txt trunk/AgateLib.SDL/lib32/README-SDL.txt trunk/AgateLib.SDL/lib32/README.txt trunk/AgateLib.SDL/lib32/SDL2.dll trunk/AgateLib.SDL/lib32/SDL2_mixer.dll trunk/AgateLib.SDL/lib32/libFLAC-8.dll trunk/AgateLib.SDL/lib32/libmikmod-2.dll trunk/AgateLib.SDL/lib32/libmodplug-1.dll trunk/AgateLib.SDL/lib32/libogg-0.dll trunk/AgateLib.SDL/lib32/libvorbis-0.dll trunk/AgateLib.SDL/lib32/libvorbisfile-3.dll trunk/AgateLib.SDL/lib32/smpeg2.dll trunk/AgateLib.SDL/lib64/ trunk/AgateLib.SDL/lib64/LICENSE.FLAC.txt trunk/AgateLib.SDL/lib64/LICENSE.mikmod.txt trunk/AgateLib.SDL/lib64/LICENSE.modplug.txt trunk/AgateLib.SDL/lib64/LICENSE.ogg-vorbis.txt trunk/AgateLib.SDL/lib64/LICENSE.smpeg.txt trunk/AgateLib.SDL/lib64/README.txt trunk/AgateLib.SDL/lib64/Readme-SDL.txt trunk/AgateLib.SDL/lib64/SDL2.dll trunk/AgateLib.SDL/lib64/SDL2_mixer.dll trunk/AgateLib.SDL/lib64/libFLAC-8.dll trunk/AgateLib.SDL/lib64/libmikmod-2.dll trunk/AgateLib.SDL/lib64/libmodplug-1.dll trunk/AgateLib.SDL/lib64/libogg-0.dll trunk/AgateLib.SDL/lib64/libvorbis-0.dll trunk/AgateLib.SDL/lib64/libvorbisfile-3.dll trunk/AgateLib.SDL/lib64/smpeg2.dll trunk/AgateLib.SDL/packages.config Removed Paths: ------------- trunk/AgateLib/IO/IFileProvider.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/AgateLib.csproj 2014-08-02 23:49:08 UTC (rev 1432) @@ -118,7 +118,8 @@ <Compile Include="InputLib\Input.cs" /> <Compile Include="InputLib\Legacy\LegacyInputHandler.cs" /> <Compile Include="InputLib\MouseButton.cs" /> - <Compile Include="IO\IFileProvider.cs"> + <Compile Include="IO\FileProvider.cs" /> + <Compile Include="IO\IReadFileProvider.cs"> <SubType>Code</SubType> </Compile> <Compile Include="DisplayLib\ImplementationBase\FrameBufferImpl.cs" /> @@ -129,6 +130,8 @@ <Compile Include="IO\IDirectory.cs" /> <Compile Include="IO\IFile.cs" /> <Compile Include="IO\IPath.cs" /> + <Compile Include="IO\IReadWriteFileProvider.cs" /> + <Compile Include="IO\IWriteFileProvider.cs" /> <Compile Include="Platform\IStopWatch.cs" /> <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -140,6 +140,10 @@ Parameters.DisplayWindowSize = Size.FromString(parm); break; + case "--novsync": + Parameters.VerticalSync = false; + break; + default: break; } @@ -157,6 +161,7 @@ { Initialize(); AutoCreateDisplayWindow(); + Display.RenderState.WaitForVerticalBlank = Parameters.VerticalSync; int retval = BeginModel(entryPoint); Modified: trunk/AgateLib/ApplicationModels/ModelParameters.cs =================================================================== --- trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -16,6 +16,7 @@ AutoCreateDisplayWindow = true; CreateFullScreenWindow = true; ApplicationName = "AgateLib Application"; + VerticalSync = true; } public ModelParameters(string[] args) : this() { @@ -28,6 +29,8 @@ public Size DisplayWindowSize { get; set; } public bool CreateFullScreenWindow { get; set; } + public bool VerticalSync { get; set; } + public string[] Arguments { get; set; } } } Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/Core.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -329,7 +329,8 @@ FileSystem.File = factory.PlatformFactory.CreateFile(); FileSystem.Path = factory.PlatformFactory.CreatePath(); - + FileProvider.Initialize(factory.PlatformFactory); + Display.Initialize(factory.DisplayFactory.CreateDisplayImpl()); Audio.Initialize(factory.AudioFactory.CreateAudioImpl()); JoystickInput.Initialize(factory.InputFactory.CreateJoystickInputImpl()); Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -139,7 +139,7 @@ /// <param name="provider"></param> /// <param name="filename"></param> /// <returns></returns> - public virtual SurfaceImpl CreateSurface(IFileProvider provider, string filename) + public virtual SurfaceImpl CreateSurface(IReadFileProvider provider, string filename) { return CreateSurface(provider.OpenRead(filename)); } Modified: trunk/AgateLib/Drivers/IPlatformFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -19,5 +19,7 @@ IO.IPath CreatePath(); IEnumerable<System.Reflection.Assembly> GetSerializationSearchAssemblies(Type objectType); + + IReadFileProvider CreateAssetFileProvider(); } } Added: trunk/AgateLib/IO/FileProvider.cs =================================================================== --- trunk/AgateLib/IO/FileProvider.cs (rev 0) +++ trunk/AgateLib/IO/FileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -0,0 +1,46 @@ +using AgateLib.Drivers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public static class FileProvider + { + static IReadFileProvider mSurfaceAssets; + static IReadFileProvider mResourceAssets; + static IReadFileProvider mMusicAssets; + static IReadFileProvider mSoundAssets; + + internal static void Initialize(IPlatformFactory platformFactory) + { + Assets = platformFactory.CreateAssetFileProvider(); + } + + public static IReadFileProvider Assets { get; private set; } + public static IReadFileProvider SurfaceAssets + { + get { return mSurfaceAssets ?? Assets; } + set { mSurfaceAssets = Assets; } + } + public static IReadFileProvider ResourceAssets + { + get { return mResourceAssets ?? Assets; } + set { mResourceAssets = Assets; } + } + public static IReadFileProvider MusicAssets + { + get { return mMusicAssets ?? Assets; } + set { mMusicAssets = Assets; } + } + public static IReadFileProvider SoundAssets + { + get { return mSoundAssets ?? Assets; } + set { mSoundAssets = Assets; } + } + + public static IReadWriteFileProvider UserFiles { get; private set; } + + } +} Deleted: trunk/AgateLib/IO/IFileProvider.cs =================================================================== --- trunk/AgateLib/IO/IFileProvider.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/IO/IFileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -1,82 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace AgateLib -{ - /// <summary> - /// Public interface that should be implemented - /// </summary> - public interface IFileProvider - { - /// <summary> - /// Opens the specified file returning a stream. Throws - /// FileNotFoundException if the file does not exist. - /// </summary> - /// <param name="filename">The path and filename of the file to read from.</param> - /// <returns></returns> - Stream OpenRead(string filename); - /// <summary> - /// Checks to if the specified file exists in the file provider. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - bool FileExists(string filename); - - /// <summary> - /// Enumerates through all filenames in the file provider. - /// </summary> - /// <returns></returns> - IEnumerable<string> GetAllFiles(); - /// <summary> - /// Enumerates through all filenames which match the specified search pattern. - /// </summary> - /// <remarks>The search pattern is not regex style pattern matching, rather it should - /// be bash pattern matching, so a searchPattern of "*" would match all files, and - /// "*.*" would match all filenames with a period in them.</remarks> - /// <param name="searchPattern"></param> - /// <returns></returns> - IEnumerable<string> GetAllFiles(string searchPattern); - /// <summary> - /// Returns a string containing the entire contents of the specified file. - /// </summary> - /// <param name="filename">The path and filename of the file to read from.</param> - /// <returns></returns> - string ReadAllText(string filename); - - /// <summary> - /// Returns true if the specified filename points to an actual file on disk. - /// If this method returns false, then ResolveFile will throw an exception - /// for that file. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - bool IsRealFile(string filename); - - /// <summary> - /// Returns the full path of the given filename. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - string ResolveFile(string filename); - } -} Copied: trunk/AgateLib/IO/IReadFileProvider.cs (from rev 1429, trunk/AgateLib/IO/IFileProvider.cs) =================================================================== --- trunk/AgateLib/IO/IReadFileProvider.cs (rev 0) +++ trunk/AgateLib/IO/IReadFileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -0,0 +1,82 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace AgateLib +{ + /// <summary> + /// Public interface that should be implemented + /// </summary> + public interface IReadFileProvider + { + /// <summary> + /// Opens the specified file returning a stream. Throws + /// FileNotFoundException if the file does not exist. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + Stream OpenRead(string filename); + /// <summary> + /// Checks to if the specified file exists in the file provider. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + bool FileExists(string filename); + + /// <summary> + /// Enumerates through all existing filenames in the file provider. + /// </summary> + /// <returns></returns> + IEnumerable<string> GetAllFiles(); + /// <summary> + /// Enumerates through all filenames which match the specified search pattern. + /// </summary> + /// <remarks>The search pattern is not regex style pattern matching, rather it should + /// be bash pattern matching, so a searchPattern of "*" would match all files, and + /// "*.*" would match all filenames with a period in them.</remarks> + /// <param name="searchPattern"></param> + /// <returns></returns> + IEnumerable<string> GetAllFiles(string searchPattern); + /// <summary> + /// Returns a string containing the entire contents of the specified file. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + string ReadAllText(string filename); + + /// <summary> + /// Returns true if the specified filename points to an actual file on disk. + /// If this method returns false, then ResolveFile will throw an exception + /// for that file. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + bool IsRealFile(string filename); + + /// <summary> + /// Returns the full path of the given filename. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + string ResolveFile(string filename); + } +} Added: trunk/AgateLib/IO/IReadWriteFileProvider.cs =================================================================== --- trunk/AgateLib/IO/IReadWriteFileProvider.cs (rev 0) +++ trunk/AgateLib/IO/IReadWriteFileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public interface IReadWriteFileProvider : IReadFileProvider, IWriteFileProvider + { + } +} Added: trunk/AgateLib/IO/IWriteFileProvider.cs =================================================================== --- trunk/AgateLib/IO/IWriteFileProvider.cs (rev 0) +++ trunk/AgateLib/IO/IWriteFileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public interface IWriteFileProvider + { + } +} Modified: trunk/AgateLib/Resources/AgateResourceCollection.cs =================================================================== --- trunk/AgateLib/Resources/AgateResourceCollection.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/Resources/AgateResourceCollection.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -43,7 +43,7 @@ const string mStringTableKey = "Strings"; bool mOwnFileProvider; - IFileProvider mFileProvider; + IReadFileProvider mFileProvider; SurfaceResourceList mSurfaceAccessor; //GuiThemeResourceList mGuiThemeAccessor; @@ -68,7 +68,7 @@ if (retval != null) return retval; } - + throw new AgateResourceException("Could not find the surface resource {0}.", key); } } @@ -78,36 +78,36 @@ get { return mResources.mImages.Count; } } } -// public class GuiThemeResourceList -// { -// AgateResourceCollection mResources; -// -// internal GuiThemeResourceList(AgateResourceCollection resources) -// { -// mResources = resources; -// } -// -// public GuiThemeResource this[string key] -// { -// get -// { -// var retval = mResources.mGuiThemes.FirstOrDefault(x => x.Name == key); -// -// if (retval == null) -// throw new AgateResourceException("Could not find the gui theme resource {0}.", key); -// -// return retval; -// } -// } -// public GuiThemeResource this[int index] -// { -// get { return mResources.mGuiThemes[index]; } -// } -// public int Count -// { -// get { return mResources.mGuiThemes.Count; } -// } -// } + // public class GuiThemeResourceList + // { + // AgateResourceCollection mResources; + // + // internal GuiThemeResourceList(AgateResourceCollection resources) + // { + // mResources = resources; + // } + // + // public GuiThemeResource this[string key] + // { + // get + // { + // var retval = mResources.mGuiThemes.FirstOrDefault(x => x.Name == key); + // + // if (retval == null) + // throw new AgateResourceException("Could not find the gui theme resource {0}.", key); + // + // return retval; + // } + // } + // public GuiThemeResource this[int index] + // { + // get { return mResources.mGuiThemes[index]; } + // } + // public int Count + // { + // get { return mResources.mGuiThemes.Count; } + // } + // } /// <summary> /// Constructs a new AgateResourceCollection object. @@ -144,9 +144,15 @@ /// <summary> /// Gets or sets the file provider used to laod resources. /// </summary> - public IFileProvider FileProvider + public IReadFileProvider FileProvider { - get { return mFileProvider; } + get + { + if (mFileProvider == null) + return AgateLib.IO.FileProvider.ResourceAssets; + + return mFileProvider; + } set { mFileProvider = value; } } @@ -186,10 +192,10 @@ /// <summary> /// Gets the list of GuiThemeResource objects. /// </summary> -// public GuiThemeResourceList GuiThemes -// { -// get { return mGuiThemeAccessor; } -// } + // public GuiThemeResourceList GuiThemes + // { + // get { return mGuiThemeAccessor; } + // } /// <summary> /// Enumerates through the DisplayWindowResources contained in this group of resources. /// </summary> @@ -234,10 +240,10 @@ mImages.Add(img); } -// else if (item is GuiThemeResource) -// { -// mGuiThemes.Add((GuiThemeResource)item); -// } + // else if (item is GuiThemeResource) + // { + // mGuiThemes.Add((GuiThemeResource)item); + // } else mStore.Add(item.Name, item); } Modified: trunk/AgateLib/Resources/ImageResource.cs =================================================================== --- trunk/AgateLib/Resources/ImageResource.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib/Resources/ImageResource.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -98,7 +98,7 @@ } public string Filename { get; set; } - public IFileProvider FileProvider { get; set; } + public IReadFileProvider FileProvider { get; set; } public List<SurfaceResource> Surfaces { get { return mSurfaces; } } Modified: trunk/AgateLib-Everything.sln =================================================================== --- trunk/AgateLib-Everything.sln 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib-Everything.sln 2014-08-02 23:49:08 UTC (rev 1432) @@ -35,6 +35,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.Platform.WindowsForms", "AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj", "{4B12561E-D37B-48A1-B6DB-218E94906C22}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.SDL", "AgateLib.SDL\AgateLib.SDL.csproj", "{935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -408,6 +410,27 @@ {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x64.ActiveCfg = Release|Any CPU {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x86.ActiveCfg = Release|x86 {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x86.Build.0 = Release|x86 + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|Win32.ActiveCfg = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|x64.ActiveCfg = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Debug|x86.ActiveCfg = Debug|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|Any CPU.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|Any CPU.Build.0 = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|Mixed Platforms.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|Mixed Platforms.Build.0 = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|Win32.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|x64.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Public|x86.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|Any CPU.Build.0 = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|Win32.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|x64.ActiveCfg = Release|Any CPU + {935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/AgateLib.GL/Properties/AssemblyInfo.cs =================================================================== --- trunk/AgateLib.GL/Properties/AssemblyInfo.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.GL/Properties/AssemblyInfo.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -5,15 +5,15 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("AgateLib.OpenGL")] +[assembly: AssemblyTitle("AgateLib.GL")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("AgateLib.OpenGL")] +[assembly: AssemblyProduct("AgateLib.GL")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: InternalsVisibleTo("AgateLib.Desktop.Forms")] +[assembly: InternalsVisibleTo("AgateLib.Platform.WindowsForms")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-08-02 23:49:08 UTC (rev 1432) @@ -143,6 +143,10 @@ <Project>{94734e5a-0344-43e8-bb30-e32e3f57f611}</Project> <Name>AgateLib.GL</Name> </ProjectReference> + <ProjectReference Include="..\AgateLib.SDL\AgateLib.SDL.csproj"> + <Project>{935d67a0-931e-46de-9f6a-2d6dbc99aff3}</Project> + <Name>AgateLib.SDL</Name> + </ProjectReference> <ProjectReference Include="..\AgateLib\AgateLib.csproj"> <Project>{9490b719-829e-43a7-a5fe-8001f8a81759}</Project> <Name>AgateLib</Name> Modified: trunk/AgateLib.Platform.WindowsForms/Configuration.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Configuration.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/Configuration.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -13,8 +13,9 @@ { public static class Configuration { + static FileProviderList mAssetProvider = new FileProviderList(); static FileProviderList mResourceProvider = new FileProviderList(); - static FileProviderList mImageProvider = new FileProviderList(); + static FileProviderList mSurfaceProvider = new FileProviderList(); static FileProviderList mSoundProvider = new FileProviderList(); static FileProviderList mMusicProvider = new FileProviderList(); @@ -29,7 +30,7 @@ } public static FileProviderList Resources { get { return mResourceProvider; } } - public static FileProviderList Images { get { return mImageProvider; } } + public static FileProviderList Images { get { return mSurfaceProvider; } } public static FileProviderList Sounds { get { return mSoundProvider; } } public static FileProviderList MusicProvider { get { return mMusicProvider; } } } Modified: trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabase.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabase.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabase.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -66,7 +66,7 @@ /// </summary> /// <param name="provider"></param> /// <returns></returns> - public static AgateDatabase FromProvider(IFileProvider provider) + public static AgateDatabase FromProvider(IReadFileProvider provider) { return ReadDatabase(provider); } @@ -79,7 +79,7 @@ ((IDisposable)mTables).Dispose(); } - private static AgateDatabase ReadDatabase(IFileProvider provider) + private static AgateDatabase ReadDatabase(IReadFileProvider provider) { XleSerializer ser = new XleSerializer(typeof(AgateDatabase)); Modified: trunk/AgateLib.Platform.WindowsForms/Data/AgateTableDictionary.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Data/AgateTableDictionary.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/Data/AgateTableDictionary.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -57,7 +57,7 @@ } } - internal IFileProvider FileProvider { get; set; } + internal IReadFileProvider FileProvider { get; set; } internal bool OwnFileProvider { get; set; } /// <summary> Modified: trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -2,8 +2,10 @@ using AgateLib.Drivers; using AgateLib.IO; using AgateLib.Platform.WindowsForms.PlatformImplementation; +using AgateLib.Utility; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -41,7 +43,22 @@ return new SysIoPath(); } + public IReadFileProvider CreateAssetFileProvider() + { + return new FileSystemProvider(AssemblyLoadDirectory); + } + static public string AssemblyLoadDirectory + { + get + { + string codeBase = Assembly.GetCallingAssembly().CodeBase; + UriBuilder uri = new UriBuilder(codeBase); + string path = Uri.UnescapeDataString(uri.Path); + return Path.GetDirectoryName(path); + } + } + public IEnumerable<Assembly> GetSerializationSearchAssemblies(Type objectType) { var assembly = Assembly.GetEntryAssembly(); Modified: trunk/AgateLib.Platform.WindowsForms/Factories/SdlFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Factories/SdlFactory.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/Factories/SdlFactory.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -16,7 +16,7 @@ public AudioLib.ImplementationBase.AudioImpl CreateAudioImpl() { - return new NullSoundImpl(); + return new AgateLib.SDL.Audio.SDL_Audio(); } } } Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileProviderList.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileProviderList.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileProviderList.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -27,9 +27,9 @@ /// Contains a list of IFileProvider objects that are used to search for /// and open files. /// </summary> - public class FileProviderList : IList<IFileProvider>, IFileProvider + public class FileProviderList : IList<IReadFileProvider>, IReadFileProvider { - List<IFileProvider> mProviders = new List<IFileProvider>(); + List<IReadFileProvider> mProviders = new List<IReadFileProvider>(); /// <summary> /// Returns the IFileProvider object which would return the specified @@ -37,7 +37,7 @@ /// </summary> /// <param name="filename"></param> /// <returns></returns> - public IFileProvider GetProvider(string filename) + public IReadFileProvider GetProvider(string filename) { for (int i = mProviders.Count - 1; i >= 0; i--) { @@ -166,7 +166,7 @@ /// </summary> /// <param name="item"></param> /// <returns></returns> - public int IndexOf(IFileProvider item) + public int IndexOf(IReadFileProvider item) { return mProviders.IndexOf(item); } @@ -176,7 +176,7 @@ /// </summary> /// <param name="index"></param> /// <param name="item"></param> - public void Insert(int index, IFileProvider item) + public void Insert(int index, IReadFileProvider item) { if (item is FileProviderList) { @@ -198,7 +198,7 @@ /// </summary> /// <param name="index"></param> /// <returns></returns> - public IFileProvider this[int index] + public IReadFileProvider this[int index] { get { @@ -222,7 +222,7 @@ /// Adds an IFileProvider to the list. /// </summary> /// <param name="item"></param> - public void Add(IFileProvider item) + public void Add(IReadFileProvider item) { if (item is FileProviderList) { @@ -242,12 +242,12 @@ /// </summary> /// <param name="item"></param> /// <returns></returns> - public bool Contains(IFileProvider item) + public bool Contains(IReadFileProvider item) { return mProviders.Contains(item); } - void ICollection<IFileProvider>.CopyTo(IFileProvider[] array, int arrayIndex) + void ICollection<IReadFileProvider>.CopyTo(IReadFileProvider[] array, int arrayIndex) { mProviders.CopyTo(array, arrayIndex); } @@ -270,7 +270,7 @@ /// </summary> /// <param name="item"></param> /// <returns></returns> - public bool Remove(IFileProvider item) + public bool Remove(IReadFileProvider item) { return mProviders.Remove(item); } @@ -282,7 +282,7 @@ /// Enumerates items. /// </summary> /// <returns></returns> - public IEnumerator<IFileProvider> GetEnumerator() + public IEnumerator<IReadFileProvider> GetEnumerator() { return mProviders.GetEnumerator(); } Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileSystemProvider.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileSystemProvider.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileSystemProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -28,7 +28,7 @@ /// FileSystemProvider implements IFileProvider, providing access to files /// from the operating system file system. /// </summary> - public class FileSystemProvider : IFileProvider + public class FileSystemProvider : IReadFileProvider { string mPath; Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/TgzFileProvider.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/TgzFileProvider.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/TgzFileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -31,7 +31,7 @@ /// tar archives. This provides basic support for reading files from a compressed /// archive external to the application. /// </summary> - public class TgzFileProvider : IFileProvider + public class TgzFileProvider : IReadFileProvider { class FileInfo { Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/ZipFileProvider.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/ZipFileProvider.cs 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/ZipFileProvider.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -32,7 +32,7 @@ /// ZipFileProvider is the deflate method, so you must make sure that any compressed /// data in the zip file is compressed with deflate. /// </summary> - public class ZipFileProvider : IFileProvider, IDisposable + public class ZipFileProvider : IReadFileProvider, IDisposable { string zipFilename; Stream inFile; Index: trunk/AgateLib.SDL =================================================================== --- trunk/AgateLib.SDL 2014-08-02 01:04:50 UTC (rev 1431) +++ trunk/AgateLib.SDL 2014-08-02 23:49:08 UTC (rev 1432) Property changes on: trunk/AgateLib.SDL ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,10 ## +[Bb]in +obj +[Dd]ebug +[Rr]elease +*.user +*.aps +*.eto +ClientBin +GeneratedArtifacts +_Pvt_Extensions Added: trunk/AgateLib.SDL/AgateLib.SDL.csproj =================================================================== --- trunk/AgateLib.SDL/AgateLib.SDL.csproj (rev 0) +++ trunk/AgateLib.SDL/AgateLib.SDL.csproj 2014-08-02 23:49:08 UTC (rev 1432) @@ -0,0 +1,188 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{935D67A0-931E-46DE-9F6A-2D6DBC99AFF3}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>AgateLib.SDL</RootNamespace> + <AssemblyName>AgateLib.SDL</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Audio\SDL_Audio.cs" /> + <Compile Include="Audio\SDL_Music.cs" /> + <Compile Include="Audio\SDL_SoundBuffer.cs" /> + <Compile Include="Audio\SDL_SoundBufferSession.cs" /> + <Compile Include="Input\SDL_Input.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Sdl2\ISDL.cs" /> + <Compile Include="Sdl2\ISDLMixer.cs" /> + <Compile Include="Sdl2\SDL32.cs" /> + <Compile Include="Sdl2\SDL64.cs" /> + <Compile Include="Sdl2\SDLConstants.cs" /> + <Compile Include="Sdl2\SdlFactory.cs" /> + <Compile Include="Sdl2\SixtyFour\LPUtf8StrMarshaler.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2_image.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2_mixer.cs" /> + <Compile Include="Sdl2\SixtyFour\SDL2_ttf.cs" /> + <Compile Include="Sdl2\ThirtyTwo\LPUtf8StrMarshaler.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2_image.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2_mixer.cs" /> + <Compile Include="Sdl2\ThirtyTwo\SDL2_ttf.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="AgateLib.SDL.dll.config"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <None Include="lib64\Readme-SDL.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\AgateLib\AgateLib.csproj"> + <Project>{9490b719-829e-43a7-a5fe-8001f8a81759}</Project> + <Name>AgateLib</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Content Include="lib32\libFLAC-8.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libmikmod-2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libmodplug-1.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libogg-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libvorbis-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\libvorbisfile-3.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.FLAC.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.mikmod.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.modplug.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.ogg-vorbis.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\LICENSE.smpeg.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\README-SDL.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\README.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\SDL2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\SDL2_mixer.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib32\smpeg2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libFLAC-8.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libmikmod-2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libmodplug-1.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libogg-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libvorbis-0.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\libvorbisfile-3.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.FLAC.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.mikmod.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.modplug.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.ogg-vorbis.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\LICENSE.smpeg.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\README.txt"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\SDL2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\SDL2_mixer.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="lib64\smpeg2.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + </ItemGroup> + <ItemGroup /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Copied: trunk/AgateLib.SDL/AgateLib.SDL.dll.config (from rev 1429, trunk/Drivers/AgateSDL/AgateSDL.dll.config) =================================================================== --- trunk/AgateLib.SDL/AgateLib.SDL.dll.config (rev 0) +++ trunk/AgateLib.SDL/AgateLib.SDL.dll.config 2014-08-02 23:49:08 UTC (rev 1432) @@ -0,0 +1,6 @@ +<configuration> + <dllmap os="linux" dll="SDL.dll" target="libSDL-1.2.so.0"/> + <dllmap os="linux" dll="SDL_mixer.dll" target="libSDL_mixer-1.2.so.0"/> + <dllmap os="osx" dll="SDL.dll" target="SDL.framework/SDL"/> + <dllmap os="osx" dll="SDL_mixer.dll" target="SDL_mixer.framework/SDL_mixer"/> +</configuration> Modified: trunk/AgateLib.SDL/Audio/SDL_Audio.cs =================================================================== --- trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs 2014-08-02 00:49:42 UTC (rev 1429) +++ trunk/AgateLib.SDL/Audio/SDL_Audio.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -22,16 +22,29 @@ using System.Text; using AgateLib; using AgateLib.AudioLib.ImplementationBase; -using Tao.Sdl; +using SDL2; +using AgateLib.SDL.Sdl2; -namespace AgateSDL.Audio +namespace AgateLib.SDL.Audio { public class SDL_Audio : AudioImpl { List<string> tempfiles = new List<string>(); Dictionary<int, SDL_SoundBufferSession> mChannels = new Dictionary<int, SDL_SoundBufferSession>(); - SdlMixer.ChannelFinishedDelegate mChannelFinishedDelegate; + Func<int> mChannelFinishedDelegate; + ISDL sdl; + public SDL_Audio() + { + sdl = SdlFactory.CreateSDL(); + + FileProvider = AgateLib.IO.FileProvider.SoundAssets; + } + public SDL_Audio(IReadFileProvider fileProvider) + { + FileProvider = fileProvider; + } + ~SDL_Audio() { Dispose(false); @@ -41,10 +54,12 @@ Dispose(true); } + public IReadFileProvider FileProvider { get; private set; } + private void Dispose(bool disposing) { - SdlMixer.Mix_CloseAudio(); - Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO); + sdl.Mixer.Mix_CloseAudio(); + sdl.SDL_QuitSubSystem(SDLConstants.SDL_INIT_AUDIO); foreach (string file in tempfiles) { @@ -73,11 +88,11 @@ public override MusicImpl CreateMusic(string filename) { - return new SDL_Music(filename); + return new SDL_Music(this, filename); } public override MusicImpl CreateMusic(System.IO.Stream musicStream) { - return new SDL_Music(musicStream); + return new SDL_Music(this, musicStream); } public override SoundBufferImpl CreateSoundBuffer(string filename) @@ -96,22 +111,22 @@ public override void Initialize() { - if (Sdl.SDL_InitSubSystem(Sdl.SDL_INIT_AUDIO) != 0) + if (sdl.SDL_InitSubSystem(SDLConstants.SDL_INIT_AUDIO) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL for audio playback."); } - if (SdlMixer.Mix_OpenAudio( - SdlMixer.MIX_DEFAULT_FREQUENCY, Sdl.AUDIO_S16, 2, 512) != 0) + if (sdl.Mixer.Mix_OpenAudio( + sdl.Mixer.MIX_DEFAULT_FREQUENCY, SDLConstants.AUDIO_S16, 2, 512) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL_mixer."); } - SdlMixer.Mix_AllocateChannels(64); + sdl.Mixer.Mix_AllocateChannels(64); mChannelFinishedDelegate = ChannelFinished; - SdlMixer.Mix_ChannelFinished(mChannelFinishedDelegate); + sdl.Mixer.Mix_ChannelFinished(mChannelFinishedDelegate); Report("SDL driver instantiated for audio."); } Modified: trunk/AgateLib.SDL/Audio/SDL_Music.cs =================================================================== --- trunk/Drivers/AgateSDL/Audio/SDL_Music.cs 2014-08-02 00:49:42 UTC (rev 1429) +++ trunk/AgateLib.SDL/Audio/SDL_Music.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -22,27 +22,33 @@ using System.Text; using AgateLib; using AgateLib.AudioLib.ImplementationBase; -using Tao.Sdl; +using SDL2; -namespace AgateSDL.Audio +namespace AgateLib.SDL.Audio { public class SDL_Music : MusicImpl { + SDL_Audio audio; IntPtr music; string tempfile; double mVolume; - public SDL_Music(Stream stream) + public SDL_Music(SDL_Audio audio, Stream stream) { - tempfile = AgateFileProvider.SaveStreamToTempFile(stream); + this.audio = audio; + throw new NotImplementedException(); + //tempfile = audio.FileProvider.SaveStreamToTempFile(stream); + LoadFromFile(tempfile); - (AgateLib.AudioLib.Audio.Impl as SDL_Audio).RegisterTempFile(tempfile); + audio.RegisterTempFile(tempfile); } - public SDL_Music(string filename) + public SDL_Music(SDL_Audio audio, string filename) { + this.audio = audio; + LoadFromFile(filename); } @@ -59,7 +65,7 @@ private void Dispose(bool disposing) { - SdlMixer.Mix_FreeMusic(music); + SDL_mixer.Mix_FreeMusic(music); //if (string.IsNullOrEmpty(tempfile) == false) //{ @@ -70,7 +76,7 @@ private void LoadFromFile(string file) { - music = SdlMixer.Mix_LoadMUS(file); + music = SDL_mixer.Mix_LoadMUS(file); if (music == IntPtr.Zero) throw new AgateException("Could not load music file."); @@ -80,10 +86,10 @@ { get { - if (SdlMixer.Mix_PlayingMusic() == 0) + if (SDL_mixer.Mix_PlayingMusic() == 0) return false; - if (SdlMixer.Mix_PausedMusic() != 0) + if (SDL_mixer.Mix_PausedMusic() != 0) return false; return true; @@ -92,7 +98,7 @@ protected override void OnSetLoop(bool value) { - SdlMixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); + SDL_mixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); } public override double Pan @@ -109,13 +115,13 @@ public override void Play() { - SdlMixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); - mVolume = SdlMixer.Mix_VolumeMusic(-1) / (double)SdlMixer.MIX_MAX_VOLUME; + SDL_mixer.Mix_PlayMusic(music, IsLooping ? -1 : 1); + mVolume = SDL_mixer.Mix_VolumeMusic(-1) / (double)SDL_mixer.MIX_MAX_VOLUME; } public override void Stop() { - SdlMixer.Mix_PauseMusic(); + SDL_mixer.Mix_PauseMusic(); } public override double Volume @@ -130,9 +136,9 @@ if (mVolume < 0) mVolume = 0; if (mVolume > 1) mVolume = 1; - int v = (int)(mVolume * SdlMixer.MIX_MAX_VOLUME); + int v = (int)(mVolume * SDL_mixer.MIX_MAX_VOLUME); - SdlMixer.Mix_VolumeMusic(v); + SDL_mixer.Mix_VolumeMusic(v); } } } Modified: trunk/AgateLib.SDL/Audio/SDL_SoundBuffer.cs =================================================================== --- trunk/Drivers/AgateSDL/Audio/SDL_SoundBuffer.cs 2014-08-02 00:49:42 UTC (rev 1429) +++ trunk/AgateLib.SDL/Audio/SDL_SoundBuffer.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -23,9 +23,9 @@ using System.Text; using AgateLib; using AgateLib.AudioLib.ImplementationBase; -using Tao.Sdl; +using SDL2; -namespace AgateSDL.Audio +namespace AgateLib.SDL.Audio { class SDL_SoundBuffer : SoundBufferImpl { @@ -37,7 +37,8 @@ public SDL_SoundBuffer(Stream stream) { - tempfile = AgateFileProvider.SaveStreamToTempFile(stream); + throw new NotImplementedException(); + //tempfile = AgateFileProvider.SaveStreamToTempFile(stream); this.filename = tempfile; LoadFromFile(tempfile); @@ -72,7 +73,7 @@ private void Dispose(bool disposing) { - SdlMixer.Mix_FreeChunk(sound); + SDL_mixer.Mix_FreeChunk(sound); //if (string.IsNullOrEmpty(tempfile) == false) //{ // File.Delete(tempfile); @@ -81,7 +82,7 @@ } private void LoadFromFile(string file) { - sound = SdlMixer.Mix_LoadWAV(file); + sound = SDL_mixer.Mix_LoadWAV(file); if (sound == IntPtr.Zero) throw new AgateException("Could not load audio file."); Modified: trunk/AgateLib.SDL/Audio/SDL_SoundBufferSession.cs =================================================================== --- trunk/Drivers/AgateSDL/Audio/SDL_SoundBufferSession.cs 2014-08-02 00:49:42 UTC (rev 1429) +++ trunk/AgateLib.SDL/Audio/SDL_SoundBufferSession.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -23,9 +23,9 @@ using System.Text; using AgateLib; using AgateLib.AudioLib.ImplementationBase; -using Tao.Sdl; +using SDL2; -namespace AgateSDL.Audio +namespace AgateLib.SDL.Audio { class SDL_SoundBufferSession : SoundBufferSessionImpl { @@ -67,7 +67,7 @@ if (channel == -1) return false; - return SdlMixer.Mix_Playing(channel) != 0; + return SDL_mixer.Mix_Playing(channel) != 0; } } @@ -100,21 +100,21 @@ byte leftVol = (byte)(pan <= 0 ? 255 : (int)((1.0 - pan) * 255)); byte rightVol = (byte)(pan >= 0 ? 255 : (int)((pan + 1.0) * 255)); - SdlMixer.Mix_SetPanning(channel, leftVol, rightVol); + SDL_mixer.Mix_SetPanning(channel, leftVol, rightVol); } public override void Play() { if (IsPlaying == false) { - channel = SdlMixer.Mix_PlayChannel(-1, sound, LoopCount); + channel = SDL_mixer.Mix_PlayChannel(-1, sound, LoopCount); if (channel == -1) - Trace.WriteLine(string.Format("Error: {0}", SdlMixer.Mix_GetError())); + Trace.WriteLine(string.Format("Error: {0}", "unknown" /*SDL_mixer.Mix_GetError() */)); } else { - SdlMixer.Mix_PlayChannel(channel, sound, LoopCount); + SDL_mixer.Mix_PlayChannel(channel, sound, LoopCount); } SetPanning(); @@ -142,7 +142,7 @@ public override void Stop() { - SdlMixer.Mix_HaltChannel(channel); + SDL_mixer.Mix_HaltChannel(channel); watch.Stop(); } @@ -165,7 +165,7 @@ { if (channel != -1) { - SdlMixer.Mix_Volume(channel, (int)(volume * 128)); + SDL_mixer.Mix_Volume(channel, (int)(volume * 128)); } } @@ -176,7 +176,7 @@ if (channel == -1) return false; else - return SdlMixer.Mix_Paused(channel) != 0; + return SDL_mixer.Mix_Paused(channel) != 0; } set { @@ -185,11 +185,11 @@ if (IsPaused) { - SdlMixer.Mix_Resume(channel); + SDL_mixer.Mix_Resume(channel); } else { - SdlMixer.Mix_Pause(channel); + SDL_mixer.Mix_Pause(channel); } } } Modified: trunk/AgateLib.SDL/Input/SDL_Input.cs =================================================================== --- trunk/Drivers/AgateSDL/Input/SDL_Input.cs 2014-08-02 00:49:42 UTC (rev 1429) +++ trunk/AgateLib.SDL/Input/SDL_Input.cs 2014-08-02 23:49:08 UTC (rev 1432) @@ -23,40 +23,43 @@ using AgateLib.Drivers; using AgateLib.InputLib.ImplementationBase; -namespace AgateSDL.Input +namespace AgateLib.SDL.Input { public class SDL_Input : InputImpl { - + public SDL_Input() + { + } public override int JoystickCount { - get { return Tao.Sdl.Sdl.SDL_NumJoysticks(); } + get { return SDL2.SDL.SDL_NumJoysticks(); } } public override IEnumerable<JoystickImpl> CreateJoysticks() { for (int i = 0; i < JoystickCount; i++) { - Debug.Print(Tao.Sdl.Sdl.SDL_JoystickName(i)); + Debug.Print(SDL2.SDL.SDL_JoystickName((IntPtr)i)); yield return new Joystick_SDL(i); } } public override void Dispose() { - Tao.Sdl.Sdl.SDL_QuitSubSystem(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK); + SDL2.SDL.SDL_QuitSubSystem(SDL2.SDL.SDL_INIT_JOYSTICK); } public override void Initialize() { // apparently initializing the video has some side-effect // that is required for joysticks to work on windows (at least). - if (Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK | Tao.Sdl.Sdl.SDL_INIT_VIDEO) != 0) + if (SDL2.SDL.SDL_InitSubSystem(SDL2.SDL.SDL_INIT_JOYSTICK | SDL2.SDL.SDL_INIT_VIDEO) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL joysticks."); } - Tao.Sdl.Sdl.SDL_version version = Tao.Sdl.Sdl.SDL_VERSION(); + SDL2.SDL.SDL_version version; + SDL2.SDL.SDL_VERSION(out version); Report("SDL driver version " + version.ToString() + " instantiated for joystick input."); @@ -66,14 +69,14 @@ public class Joystick_SDL : JoystickImpl { IntPtr joystick; - int joystickIndex; + IntPtr joystickIndex; double axisTheshold = 0.04f; bool[] buttons; public Joystick_SDL(int index) { - this.joystickIndex = index; - this.joystick = Tao.Sdl.Sdl.SDL_JoystickOpen(index); + this.joystickIndex = (IntPtr) index; + this.joystick = SDL2.SDL.SDL_JoystickOpen(index); buttons = new bool[ButtonCount]; } @@ -81,7 +84,7 @@ { get { - string retval = Tao.Sdl.Sdl.SDL_JoystickName(joystickIndex); + string retval = SDL2.SDL.SDL_JoystickName(joystickIndex); return retval; } @@ -89,11 +92,11 @@ public override int AxisCount { - get { return Tao.Sdl.Sdl.SDL_JoystickNumAxes(joystick); } + get { return SDL2.SDL.SDL_JoystickNumAxes(joystick); } } public override int HatCount { - get { return Tao.Sdl.Sdl.SDL_JoystickNumHats(joystick); } + get { return SDL2.SDL.SDL_JoystickNumHats(joystick); } } public override double AxisThreshold @@ -110,7 +113,7 @@ public override int ButtonCount { - get { return Tao.Sdl.Sdl.SDL_JoystickNumButtons(joystick); } + get { return SDL2.SDL.SDL_JoystickNumButtons(joystick); } } public override bool GetButtonState(int buttonIndex) @@ -119,18 +122,18 @@ } public override AgateLib.InputLib.HatState GetHatState(int hatIndex) { - switch(Tao.Sdl.Sdl.SDL_JoystickGetHat(joystick, hatIndex)) + switch(SDL2.SDL.SDL_JoystickGetHat(joystick, hatIndex)) { - case Tao.Sdl.Sdl.SDL_HAT_RIGHTUP: return AgateLib.InputLib.HatState.UpRight; - case Tao.Sdl.Sdl.SDL_HAT_RIGHT: return AgateLib.InputLib.HatState.Right; - case Tao.Sdl.Sdl.SDL_HAT_RIGHTDOWN: return AgateLib.InputLib.HatState.DownRight; - case Tao.Sdl.Sdl.SDL_HAT_LEFTUP: return AgateLib.InputLib.HatState.UpLeft; - case Tao.Sdl.Sdl.SDL_HAT_LEFT: return AgateLib.InputLib.HatState.Left; - case Tao.Sdl.Sdl.SDL_HAT_LEFTDOWN: return AgateLib.InputLib.HatState.DownLeft; - case Tao.Sdl.Sdl.SDL_HAT_DOWN: return AgateLib.InputLib.HatState.Down; - case Tao.Sdl.Sdl.SDL_HAT_UP: return AgateLib.InputLib.HatState.Up; + case SDL2.SDL.SDL_HAT_RIGHTUP: return AgateLib.InputLib.HatState.UpRight; + case SDL2.SDL.SDL_HAT_RIGHT: return AgateLib.InputLib.HatState.Right; + case SDL2.SDL.SDL_HAT_RIGHTDOWN: return AgateLib.InputLib.HatState.DownRight; + case SDL2.SDL.SDL_HAT_LEFTUP: return AgateLib.InputLib.HatState.UpLeft; + case SDL2.SDL.SDL_HAT_LEFT: return AgateLib.InputLib.HatState.Left; + case SDL2.SDL.SDL_HAT_LEFTDOWN: return AgateLib.InputLib.HatState.DownLeft; + case SDL2.SDL.SDL_HAT_DOWN: return AgateLib.InputLib.HatState.Down; + case SDL2.SDL.SDL_HAT_UP: return AgateLib.InputLib.HatState.Up; - case Tao.Sdl.Sdl.SDL_HAT_CENTERED: + case SDL2.SDL.SDL_HAT_CENTERED: default: return AgateLib.InputLib.HatState.None; } @@ -138,7 +141,7 @@ public override double GetAxisValue(int axisIndex) { // Convert joystick coordinate to the agatelib coordinate system of -1..1. - double value = Tao.Sdl.Sdl.SDL_JoystickGetAxis(joystick, axisIndex) / 32767.0; + double value = SDL2.SDL.SDL_JoystickGetAxis(joystick, axisIndex) / 32767.0; if (value < ... [truncated message content] |
From: <ka...@us...> - 2014-08-02 01:04:58
|
Revision: 1431 http://sourceforge.net/p/agate/code/1431 Author: kanato Date: 2014-08-02 01:04:50 +0000 (Sat, 02 Aug 2014) Log Message: ----------- Fix broken unit tests Modified Paths: -------------- trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs Modified: trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs =================================================================== --- trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs 2014-08-02 00:58:06 UTC (rev 1430) +++ trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs 2014-08-02 01:04:50 UTC (rev 1431) @@ -50,32 +50,32 @@ } internal InputEventArgs(KeyCode keyID, KeyModifiers mods) { + Initialize(); + KeyCode = keyID; KeyString = Keyboard.GetKeyString(keyID, mods); Modifiers = mods; - - Initialize(); } [Obsolete("Don't use this one.", true)] internal InputEventArgs(KeyCode keyID, KeyModifiers mods, int repeatCount) : this(keyID, mods) { + Initialize(); + mRepeatCount = repeatCount; } internal InputEventArgs(MouseButton mouseButtons) { - args = new AgateInputEventArgs(); + Initialize(); + MouseButtons = mouseButtons; - - Initialize(); } internal InputEventArgs(int wheelDelta) { - args = new AgateInputEventArgs(); + Initialize(); + WheelDelta = wheelDelta; - - Initialize(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-08-02 00:58:15
|
Revision: 1430 http://sourceforge.net/p/agate/code/1430 Author: kanato Date: 2014-08-02 00:58:06 +0000 (Sat, 02 Aug 2014) Log Message: ----------- Fix reference to AgateLib.dll project. Modified Paths: -------------- trunk/AgateLib.GL/AgateLib.GL.csproj Modified: trunk/AgateLib.GL/AgateLib.GL.csproj =================================================================== --- trunk/AgateLib.GL/AgateLib.GL.csproj 2014-08-02 00:49:42 UTC (rev 1429) +++ trunk/AgateLib.GL/AgateLib.GL.csproj 2014-08-02 00:58:06 UTC (rev 1430) @@ -134,6 +134,12 @@ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\AgateLib\AgateLib.csproj"> + <Project>{9490b719-829e-43a7-a5fe-8001f8a81759}</Project> + <Name>AgateLib</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-08-02 00:49:50
|
Revision: 1429 http://sourceforge.net/p/agate/code/1429 Author: kanato Date: 2014-08-02 00:49:42 +0000 (Sat, 02 Aug 2014) Log Message: ----------- Reorganize input into legacy namespace. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib/Diagnostics/AgateConsole.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs trunk/AgateLib/InputLib/Joystick.cs trunk/AgateLib.GL/AgateLib.GL.csproj trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs trunk/Examples/BallBuster.Net/main.cs trunk/Examples/Pong/Pong.cs trunk/Examples/ShootTheTraps/App.cs trunk/Tests/AudioTests/SoundbufferStopTester.cs trunk/Tests/CoreTests/App.cs trunk/Tests/DisplayTests/FullScreen.cs trunk/Tests/DisplayTests/Interpolation.cs trunk/Tests/DisplayTests/MultipleFramebufferTest.cs trunk/Tests/DisplayTests/PixelBufferMask.cs trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs trunk/Tests/DisplayTests/RotatingSpriteTester.cs trunk/Tests/DisplayTests/ScreenCapture.cs trunk/Tests/Fonts/FontAlignment.cs trunk/Tests/Fonts/FontLineTester.cs trunk/Tests/Fonts/Fonts.cs trunk/Tests/Fonts/Kerning.cs trunk/Tests/InputTests/Input/frmInputTester.cs trunk/Tests/Shaders/CoordinateSystem.cs trunk/Tests/Shaders/Hlsl.cs trunk/Tests/Shaders/Lighting3DTest.cs trunk/Tests/Shaders/LightingTest/LightingTest.cs trunk/UnitTests/Core/ConsoleTests.cs Added Paths: ----------- trunk/AgateLib/InputLib/AgateInputEventArgs.cs trunk/AgateLib/InputLib/IInputHandler.cs trunk/AgateLib/InputLib/Input.cs trunk/AgateLib/InputLib/InputHandlerList.cs trunk/AgateLib/InputLib/Legacy/ trunk/AgateLib/InputLib/Legacy/Delegates.cs trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs trunk/AgateLib/InputLib/Legacy/Keyboard.cs trunk/AgateLib/InputLib/Legacy/LegacyInputHandler.cs trunk/AgateLib/InputLib/Legacy/Mouse.cs trunk/AgateLib/InputLib/MouseButton.cs trunk/Examples/ShootTheTraps/Resources/timecannonimages/ Removed Paths: ------------- trunk/AgateLib/InputLib/Delegates.cs trunk/AgateLib/InputLib/InputEventArgs.cs trunk/AgateLib/InputLib/Keyboard.cs trunk/AgateLib/InputLib/Mouse.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/AgateLib.csproj 2014-08-02 00:49:42 UTC (rev 1429) @@ -112,11 +112,17 @@ <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> <Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" /> + <Compile Include="InputLib\AgateInputEventArgs.cs" /> + <Compile Include="InputLib\IInputHandler.cs" /> + <Compile Include="InputLib\InputHandlerList.cs" /> + <Compile Include="InputLib\Input.cs" /> + <Compile Include="InputLib\Legacy\LegacyInputHandler.cs" /> + <Compile Include="InputLib\MouseButton.cs" /> <Compile Include="IO\IFileProvider.cs"> <SubType>Code</SubType> </Compile> <Compile Include="DisplayLib\ImplementationBase\FrameBufferImpl.cs" /> - <Compile Include="InputLib\Delegates.cs" /> + <Compile Include="InputLib\Legacy\Delegates.cs" /> <Compile Include="InputLib\HatState.cs" /> <Compile Include="InputLib\JoystickEventArgs.cs" /> <Compile Include="IO\FileSystem.cs" /> @@ -353,7 +359,7 @@ <Compile Include="DisplayLib\ImplementationBase\VertexBufferImpl.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="InputLib\InputEventArgs.cs"> + <Compile Include="InputLib\Legacy\InputEventArgs.cs"> <SubType>Code</SubType> </Compile> <Compile Include="InputLib\Joystick.cs"> @@ -362,7 +368,7 @@ <Compile Include="InputLib\JoystickInput.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="InputLib\Keyboard.cs"> + <Compile Include="InputLib\Legacy\Keyboard.cs"> <SubType>Code</SubType> </Compile> <Compile Include="InputLib\KeyCode.cs"> @@ -371,7 +377,7 @@ <Compile Include="InputLib\KeyModifiers.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="InputLib\Mouse.cs"> + <Compile Include="InputLib\Legacy\Mouse.cs"> <SubType>Code</SubType> </Compile> <Compile Include="Particles\Particle.cs"> Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -1,5 +1,6 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; +using AgateLib.InputLib; using System; using System.Collections.Generic; using System.Linq; @@ -227,6 +228,9 @@ public ModelParameters Parameters { get; set; } - public abstract void KeepAlive(); + public virtual void KeepAlive() + { + Input.DispatchEvents(); + } } } Modified: trunk/AgateLib/Diagnostics/AgateConsole.cs =================================================================== --- trunk/AgateLib/Diagnostics/AgateConsole.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/Diagnostics/AgateConsole.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -3,6 +3,7 @@ using AgateLib.DisplayLib.Shaders; using AgateLib.Geometry; using AgateLib.InputLib; +using AgateLib.InputLib.Legacy; using System; using System.Collections.Generic; using System.Linq; Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -111,7 +111,7 @@ protected void SetInternalMousePosition(AgateLib.Geometry.Point pt) { - AgateLib.InputLib.Mouse.SetStoredPosition(pt); + AgateLib.InputLib.Legacy.Mouse.SetStoredPosition(pt); } /// <summary> Added: trunk/AgateLib/InputLib/AgateInputEventArgs.cs =================================================================== --- trunk/AgateLib/InputLib/AgateInputEventArgs.cs (rev 0) +++ trunk/AgateLib/InputLib/AgateInputEventArgs.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,62 @@ +using AgateLib.Geometry; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib +{ + public class AgateInputEventArgs : EventArgs + { + public object Sender { get; set; } + public bool Handled { get; set; } + + public InputEventType InputEventType { get; set; } + + public KeyCode KeyCode { get; set; } + public string KeyString { get; set; } + public KeyModifiers KeyModifiers { get; set; } + + public Point MousePosition { get; set; } + public MouseButton MouseButton { get; set; } + public int MouseWheelDelta { get; set; } + + + internal static AgateInputEventArgs KeyDown(KeyCode code, KeyModifiers modifiers) + { + return new AgateInputEventArgs + { + InputEventType = InputEventType.KeyDown, + KeyCode = code, + KeyModifiers = modifiers, + }; + } + + internal static AgateInputEventArgs KeyUp(KeyCode code, KeyModifiers modifiers) + { + return new AgateInputEventArgs + { + InputEventType = InputEventType.KeyUp, + KeyCode = code, + KeyModifiers = modifiers, + }; + } + } + + public enum InputEventType + { + KeyDown, + KeyPress, + KeyUp, + + MouseDown, + MouseMove, + MouseUp, + + JoystickAxisChanged, + JoystickButton, + JoystickPovHat, + MouseWheel, + + } +} Deleted: trunk/AgateLib/InputLib/Delegates.cs =================================================================== --- trunk/AgateLib/InputLib/Delegates.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/InputLib/Delegates.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AgateLib.InputLib -{ - /// <summary> - /// Input Event handler event type. - /// </summary> - /// <param name="e"></param> - public delegate void InputEventHandler(InputEventArgs e); - - public delegate void JoystickEventHandler(object sender, JoystickEventArgs e); -} Added: trunk/AgateLib/InputLib/IInputHandler.cs =================================================================== --- trunk/AgateLib/InputLib/IInputHandler.cs (rev 0) +++ trunk/AgateLib/InputLib/IInputHandler.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib +{ + public interface IInputHandler + { + void ProcessEvent(AgateInputEventArgs args); + + bool ForwardUnhandledEvents { get; } + } +} Added: trunk/AgateLib/InputLib/Input.cs =================================================================== --- trunk/AgateLib/InputLib/Input.cs (rev 0) +++ trunk/AgateLib/InputLib/Input.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib +{ + public static class Input + { + static List<AgateInputEventArgs> mEvents = new List<AgateInputEventArgs>(); + static InputHandlerList mInputHandlers = new InputHandlerList(); + + public static void QueueInputEvent(AgateInputEventArgs args) + { + lock(mEvents) + { + mEvents.Add(args); + } + } + + public static void DispatchEvents() + { + while (mEvents.Count > 0) + { + AgateInputEventArgs args; + + lock(mEvents) + { + args = mEvents[0]; + mEvents.RemoveAt(0); + } + + DispatchEvents(args); + } + } + + private static void DispatchEvents(AgateInputEventArgs args) + { + mInputHandlers.Dispatch(args); + } + + public static InputHandlerList InputHandlers { get { return mInputHandlers; } } + } +} Deleted: trunk/AgateLib/InputLib/InputEventArgs.cs =================================================================== --- trunk/AgateLib/InputLib/InputEventArgs.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/InputLib/InputEventArgs.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -1,125 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; -using AgateLib.Geometry; - -namespace AgateLib.InputLib -{ - /// <summary> - /// Class which describes details about an input event. - /// </summary> - public class InputEventArgs - { - KeyCode mKeyCode; - KeyModifiers mModifiers; - int mRepeatCount; - string mKeyString; - Point mMousePosition; - Mouse.MouseButtons mButtons; - int mWheelDelta; - - internal InputEventArgs() - { - Initialize(); - } - internal InputEventArgs(KeyCode keyID, KeyModifiers mods) - { - mKeyCode = keyID; - mKeyString = Keyboard.GetKeyString(keyID, mods); - mModifiers = mods; - - Initialize(); - } - internal InputEventArgs(KeyCode keyID, KeyModifiers mods, int repeatCount) - : this(keyID, mods) - { - mRepeatCount = repeatCount; - } - - internal InputEventArgs(Mouse.MouseButtons mouseButtons) - { - mButtons = mouseButtons; - - Initialize(); - } - internal InputEventArgs(int wheelDelta) - { - mWheelDelta = wheelDelta; - - Initialize(); - } - - private void Initialize() - { - mMousePosition = Mouse.Position; - } - - /// <summary> - /// Gets which key was pressed. - /// </summary> - public KeyCode KeyCode - { - get { return mKeyCode; } - internal set { mKeyCode = value; } - } - /// <summary> - /// Gets the text created by the key which was pressed. - /// </summary> - public string KeyString - { - get { return mKeyString; } - } - - /// <summary> - /// The mouse position during this event - /// </summary> - public Point MousePosition - { - get { return mMousePosition; } - } - - /// <summary> - /// Gets how many times the keypress has been repeated. - /// This is zero for the first time a key is pressed, and increases - /// as the key is held down and KeyDown events are generated after that. - /// </summary> - public int RepeatCount - { - get { return mRepeatCount; } - } - - /// <summary> - /// Gets which mouse buttons were pressed. - /// </summary> - public Mouse.MouseButtons MouseButtons - { - get { return mButtons; } - } - - /// <summary> - /// Gets the amount the mouse wheel moved in this event. - /// </summary> - public int WheelDelta - { - get { return mWheelDelta; } - } - } -} Added: trunk/AgateLib/InputLib/InputHandlerList.cs =================================================================== --- trunk/AgateLib/InputLib/InputHandlerList.cs (rev 0) +++ trunk/AgateLib/InputLib/InputHandlerList.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib +{ + public class InputHandlerList + { + List<IInputHandler> mHandlers = new List<IInputHandler>(); + + public InputHandlerList() + { + Add(new AgateLib.InputLib.Legacy.LegacyInputHandler()); + } + public void Add(IInputHandler handler) + { + if (mHandlers.Contains(handler)) + throw new InvalidOperationException("Cannot add the same input handler twice."); + + mHandlers.Add(handler); + } + public bool Remove(IInputHandler handler) + { + return mHandlers.Remove(handler); + } + + public void Dispatch(AgateInputEventArgs args) + { + for (int i = mHandlers.Count - 1; i >= 0; i--) + { + var handler = mHandlers[i]; + + handler.ProcessEvent(args); + + if (args.Handled) + break; + + if (handler.ForwardUnhandledEvents == false) + break; + } + } + } +} Modified: trunk/AgateLib/InputLib/Joystick.cs =================================================================== --- trunk/AgateLib/InputLib/Joystick.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/InputLib/Joystick.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -21,6 +21,7 @@ using System.Text; using AgateLib.Geometry; using AgateLib.InputLib.ImplementationBase; +using AgateLib.InputLib.Legacy; namespace AgateLib.InputLib { Deleted: trunk/AgateLib/InputLib/Keyboard.cs =================================================================== --- trunk/AgateLib/InputLib/Keyboard.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/InputLib/Keyboard.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -1,466 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; - -using AgateLib.Geometry; -using AgateLib.Diagnostics; - -namespace AgateLib.InputLib -{ - /// <summary> - /// Static class which represents Keyboard input. - /// </summary> - [CLSCompliant(true)] - public static class Keyboard - { - static KeyState mKeyState = new KeyState(); - - static Keyboard() - { - DisplayLib.Display.DisposeDisplay += new AgateLib.DisplayLib.Display.DisposeDisplayHandler(Display_DisposeDisplay); - } - - static void Display_DisposeDisplay() - { - ClearEvents(); - } - - - /// <summary> - /// Class which represents the state of all keys on the keyboard. - /// </summary> - [CLSCompliant(true)] - public class KeyState - { - private static int[] mKeyState; - private static bool[] mWaitForKeyUp; - - internal KeyState() - { - mKeyState = new int[256]; - mWaitForKeyUp = new bool[256]; - } - - /// <summary> - /// Gets or sets the state of the given key. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public bool this[KeyCode id] - { - get - { - if (mKeyState[(int)id] > 0) - return true; - else - return false; - } - set - { - int intID = (int)id; - - if (value == true) - { - if (mKeyState[intID] == 0 && mWaitForKeyUp[intID]) - return; - - mKeyState[intID]++; - mWaitForKeyUp[intID] = true; - - //System.Diagnostics.Debug.WriteLine("Set key {0} to {1}, repeat count {2}.", - // id, value, mKeyState[(int)id] - 1); - - Keyboard.OnKeyDown(id, - new KeyModifiers(this[KeyCode.Alt], this[KeyCode.Control], this[KeyCode.Shift]), - mKeyState[(int)id] - 1); - } - // value is false here: - else if (mKeyState[(int)id] > 0) - { - ReleaseKey(id, false); - } - else - { - mWaitForKeyUp[intID] = false; - } - } - } - - /// <summary> - /// Clears the key-down status of a key, and generates a KeyUp event. - /// If waitKeyUp is true, the key is marked so that KeydDown events will not be generated until - /// it has been physically released by the user. - /// </summary> - /// <param name="id">KeyCode identifier of key to release.</param> - /// <param name="waitKeyUp">Boolean flag indicating whether or not - /// keydown events should be suppressed until the key is physically released.</param> - internal void ReleaseKey(KeyCode id, bool waitKeyUp) - { - mKeyState[(int)id] = 0; - mWaitForKeyUp[(int)id] = waitKeyUp; - //System.Diagnostics.Debug.WriteLine("Set key {0} to {1}.", id, false); - - Keyboard.OnKeyUp(id, - new KeyModifiers(this[KeyCode.Alt], this[KeyCode.Control], this[KeyCode.Shift])); - } - internal bool AnyKeyPressed - { - get - { - for (int i = 0; i < mKeyState.Length; i++) - if (mKeyState[i] > 0) - return true; - - return false; - } - } - - /// <summary> - /// Resets all keys to being in the up state (not pushed). - /// Does generate KeyUp events. - /// - /// This also makes it so any keys which were depressed must be released - /// before KeyDown events are raised again. - /// </summary> - internal void ReleaseAllKeys(bool waitForKeyUp) - { - for (int i = 0; i < mKeyState.Length; i++) - { - if (mKeyState[i] > 0) - ReleaseKey((KeyCode)i, waitForKeyUp); - } - } - - - } - - /// <summary> - /// Gets an object representing the state of all keys on the keyboard. - /// </summary> - public static KeyState Keys - { - get { return mKeyState; } - } - - /// <summary> - /// Resets all keys to being in the up state (not pushed). - /// Does generate KeyUp events. - /// - /// This also makes it so any keys which were depressed must be released - /// before KeyDown events are raised again. - /// </summary> - public static void ReleaseAllKeys() - { - mKeyState.ReleaseAllKeys(true); - } - /// <summary> - /// Resets all keys to being in the up state (not pushed). - /// Does generate KeyUp events. - /// <para> - /// This can also make it so any keys which were depressed must be released - /// before KeyDown events are raised again. - /// </para> - /// </summary> - /// <param name="waitForKeyUp">If true, then keys currently depressed will - /// not generate KeyDown events until they are released.</param> - public static void ReleaseAllKeys(bool waitForKeyUp) - { - mKeyState.ReleaseAllKeys(waitForKeyUp); - } - - /// <summary> - /// Resets a particular key to being in the up state (not pushed). - /// Generates a KeyUp event for that key. - /// <para> - /// This also makes it so that the key must be physically depressed by the user - /// before it will register a KeyDown event again. If it is already depressed, - /// it must be released first. - /// </para> - /// </summary> - /// <param name="key"></param> - public static void ReleaseKey(KeyCode key) - { - mKeyState.ReleaseKey(key, true); - } - /// <summary> - /// Resets a particular key to being in the up state (not pushed). - /// Generates a KeyUp event for that key. - /// </summary> - /// <param name="key">The key to be released.</param> - /// <param name="waitForKeyUp">If true, then keys currently depressed will - /// not generate KeyDown events until they are released.</param> - public static void ReleaseKey(KeyCode key, bool waitForKeyUp) - { - mKeyState.ReleaseKey(key, waitForKeyUp); - } - - /// <summary> - /// Checks to see if the user pressed the "Any" key. - /// </summary> - public static bool AnyKeyPressed - { - get - { - return Keys.AnyKeyPressed; - } - } - private static void OnKeyDown(KeyCode id, KeyModifiers mods, int repeatCount) - { - var eventArgs = new InputEventArgs(id, mods, repeatCount); - - if (AgateConsole.IsInitialized && - (AgateConsole.IsVisible || id == AgateConsole.VisibleToggleKey)) - { - AgateConsole.Keyboard_KeyDown(eventArgs); - } - else if (KeyDown != null) - KeyDown(eventArgs); - } - private static void OnKeyUp(KeyCode id, KeyModifiers mods) - { - var eventArgs = new InputEventArgs(id, mods); - - if (AgateConsole.IsVisible) - { - AgateConsole.Keyboard_KeyUp(eventArgs); - } - else if (KeyUp != null) - KeyUp(eventArgs); - } - - /// <summary> - /// Creates a string from the specified KeyCode and KeyModifiers. - /// Unfortunately this is tied to the US English keyboard, so it needs a better solution. - /// </summary> - /// <param name="keyID"></param> - /// <param name="mods"></param> - /// <returns></returns> - public static string GetKeyString(KeyCode keyID, KeyModifiers mods) - { - if ((int)keyID >= 'A' && (int)keyID <= 'Z') - { - char result; - - if (mods.Shift) - result = (char)keyID; - else - result = (char)((int)keyID + 'a' - 'A'); - - return result.ToString(); - } - - - switch (keyID) - { - case KeyCode.Tab: - return "\t"; - - case KeyCode.Return: - //case KeyCode.Enter: - return "\n"; - - case KeyCode.Space: - return " "; - - // I'd love a better way of doing this: - // likely, this is not very friendly to non US keyboard layouts. - case KeyCode.D0: - if (mods.Shift) - return ")"; - else - return "0"; - - case KeyCode.NumPad0: - return "0"; - - case KeyCode.D1: - if (mods.Shift) - return "!"; - else return "1"; - - - case KeyCode.NumPad1: - return "1"; - - case KeyCode.D2: - if (mods.Shift) - return "@"; - else return "2"; - - case KeyCode.NumPad2: - return "2"; - - case KeyCode.D3: - if (mods.Shift) - return "#"; - else return "3"; - - case KeyCode.NumPad3: - return "3"; - - case KeyCode.D4: - if (mods.Shift) - return "$"; - else return "4"; - - case KeyCode.NumPad4: - return "4"; - - case KeyCode.D5: - if (mods.Shift) - return "%"; - else return "5"; - - case KeyCode.NumPad5: - return "5"; - - case KeyCode.D6: - if (mods.Shift) - return "^"; - else return "6"; - - case KeyCode.NumPad6: - return "6"; - - case KeyCode.D7: - if (mods.Shift) - return "&"; - else return "7"; - - case KeyCode.NumPad7: - return "7"; - - case KeyCode.D8: - if (mods.Shift) - return "*"; - else return "8"; - - - case KeyCode.NumPad8: - return "8"; - - case KeyCode.D9: - if (mods.Shift) - return "("; - else return "9"; - - case KeyCode.NumPad9: - return "9"; - - case KeyCode.NumPadMinus: - return "-"; - case KeyCode.NumPadMultiply: - return "*"; - case KeyCode.NumPadPeriod: - return "."; - case KeyCode.NumPadPlus: - return "+"; - case KeyCode.NumPadSlash: - return "/"; - - case KeyCode.Semicolon: - if (mods.Shift) - return ":"; - else - return ";"; - - case KeyCode.Plus: - if (mods.Shift) - return "+"; - else - return "="; - - case KeyCode.Comma: - if (mods.Shift) - return "<"; - else - return ","; - - case KeyCode.Minus: - if (mods.Shift) - return "_"; - else - return "-"; - - case KeyCode.Period: - if (mods.Shift) - return ">"; - else - return "."; - - case KeyCode.Slash: - if (mods.Shift) - return "?"; - else - return "/"; - - case KeyCode.Tilde: - if (mods.Shift) - return "~"; - else - return "`"; - - case KeyCode.OpenBracket: - if (mods.Shift) - return "{"; - else - return "["; - - case KeyCode.BackSlash: - if (mods.Shift) - return "|"; - else - return @"\"; - - case KeyCode.CloseBracket: - if (mods.Shift) - return "}"; - else - return "]"; - - case KeyCode.Quotes: - if (mods.Shift) - return "\""; - else - return "'"; - - } - - return ""; - } - - /// <summary> - /// Event which occurs when a key is pressed. - /// </summary> - public static event InputEventHandler KeyDown; - /// <summary> - /// Event which occurs when a key is released. - /// </summary> - public static event InputEventHandler KeyUp; - - - private static void ClearEvents() - { - KeyDown = null; - KeyUp = null; - } - } -} Copied: trunk/AgateLib/InputLib/Legacy/Delegates.cs (from rev 1422, trunk/AgateLib/InputLib/Delegates.cs) =================================================================== --- trunk/AgateLib/InputLib/Legacy/Delegates.cs (rev 0) +++ trunk/AgateLib/InputLib/Legacy/Delegates.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib.Legacy +{ + /// <summary> + /// Input Event handler event type. + /// </summary> + /// <param name="e"></param> + public delegate void InputEventHandler(InputEventArgs e); + + public delegate void JoystickEventHandler(object sender, JoystickEventArgs e); +} Copied: trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs (from rev 1422, trunk/AgateLib/InputLib/InputEventArgs.cs) =================================================================== --- trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs (rev 0) +++ trunk/AgateLib/InputLib/Legacy/InputEventArgs.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,144 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; +using AgateLib.Geometry; + +namespace AgateLib.InputLib.Legacy +{ + /// <summary> + /// Class which describes details about an input event. + /// </summary> + [Obsolete("Use AgateInputEventArgs instead.")] + public class InputEventArgs + { + private AgateInputEventArgs args; + int mRepeatCount; + + internal InputEventArgs(AgateInputEventArgs args) + { + this.args = args; + Initialize(); + } + private void Initialize() + { + if (args == null) + args = new AgateInputEventArgs(); + + MousePosition = Mouse.Position; + } + internal InputEventArgs() + { + Initialize(); + } + internal InputEventArgs(KeyCode keyID, KeyModifiers mods) + { + KeyCode = keyID; + KeyString = Keyboard.GetKeyString(keyID, mods); + Modifiers = mods; + + Initialize(); + } + [Obsolete("Don't use this one.", true)] + internal InputEventArgs(KeyCode keyID, KeyModifiers mods, int repeatCount) + : this(keyID, mods) + { + mRepeatCount = repeatCount; + } + + internal InputEventArgs(MouseButton mouseButtons) + { + args = new AgateInputEventArgs(); + MouseButtons = mouseButtons; + + Initialize(); + } + internal InputEventArgs(int wheelDelta) + { + args = new AgateInputEventArgs(); + WheelDelta = wheelDelta; + + Initialize(); + } + + + + /// <summary> + /// Gets which key was pressed. + /// </summary> + public KeyCode KeyCode + { + get { return args.KeyCode; } + internal set { args.KeyCode = value; } + } + /// <summary> + /// Gets the text created by the key which was pressed. + /// </summary> + public string KeyString + { + get { return args.KeyString; } + internal set { args.KeyString = value; } + } + + /// <summary> + /// The mouse position during this event + /// </summary> + public Point MousePosition + { + get { return args.MousePosition; } + internal set { args.MousePosition = value; } + } + + /// <summary> + /// Gets how many times the keypress has been repeated. + /// This is zero for the first time a key is pressed, and increases + /// as the key is held down and KeyDown events are generated after that. + /// </summary> + [Obsolete("Use KeyPress event instead.", true)] + public int RepeatCount + { + get { return mRepeatCount; } + } + + /// <summary> + /// Gets which mouse buttons were pressed. + /// </summary> + public MouseButton MouseButtons + { + get { return args.MouseButton; } + internal set { args.MouseButton = value; } + } + + /// <summary> + /// Gets the amount the mouse wheel moved in this event. + /// </summary> + public int WheelDelta + { + get { return args.MouseWheelDelta; } + internal set { args.MouseWheelDelta = value; } + } + + public KeyModifiers Modifiers + { + get { return args.KeyModifiers; } + set { args.KeyModifiers = value; } + } + } +} Copied: trunk/AgateLib/InputLib/Legacy/Keyboard.cs (from rev 1422, trunk/AgateLib/InputLib/Keyboard.cs) =================================================================== --- trunk/AgateLib/InputLib/Legacy/Keyboard.cs (rev 0) +++ trunk/AgateLib/InputLib/Legacy/Keyboard.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,483 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; + +using AgateLib.Geometry; +using AgateLib.Diagnostics; + +namespace AgateLib.InputLib.Legacy +{ + /// <summary> + /// Static class which represents Keyboard input. + /// </summary> + [CLSCompliant(true)] + public static class Keyboard + { + static KeyState mKeyState = new KeyState(); + + static Keyboard() + { + DisplayLib.Display.DisposeDisplay += new AgateLib.DisplayLib.Display.DisposeDisplayHandler(Display_DisposeDisplay); + } + + static void Display_DisposeDisplay() + { + ClearEvents(); + } + + + /// <summary> + /// Class which represents the state of all keys on the keyboard. + /// </summary> + [CLSCompliant(true)] + public class KeyState + { + private static int[] mKeyState; + private static bool[] mWaitForKeyUp; + + internal KeyState() + { + mKeyState = new int[256]; + mWaitForKeyUp = new bool[256]; + } + + /// <summary> + /// Gets or sets the state of the given key. + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public bool this[KeyCode id] + { + get + { + if (mKeyState[(int)id] > 0) + return true; + else + return false; + } + set + { + int intID = (int)id; + + if (value == true) + { + if (mKeyState[intID] == 0 && mWaitForKeyUp[intID]) + return; + + mKeyState[intID]++; + mWaitForKeyUp[intID] = true; + + //System.Diagnostics.Debug.WriteLine("Set key {0} to {1}, repeat count {2}.", + // id, value, mKeyState[(int)id] - 1); + + Input.QueueInputEvent(AgateInputEventArgs.KeyDown(id, CurrentModifiers)); + } + // value is false here: + else if (mKeyState[(int)id] > 0) + { + ReleaseKey(id, false); + } + else + { + mWaitForKeyUp[intID] = false; + } + } + } + + private KeyModifiers CurrentModifiers + { + get { return new KeyModifiers(this[KeyCode.Alt], this[KeyCode.Control], this[KeyCode.Shift]); } + } + + /// <summary> + /// Clears the key-down status of a key, and generates a KeyUp event. + /// If waitKeyUp is true, the key is marked so that KeydDown events will not be generated until + /// it has been physically released by the user. + /// </summary> + /// <param name="id">KeyCode identifier of key to release.</param> + /// <param name="waitKeyUp">Boolean flag indicating whether or not + /// keydown events should be suppressed until the key is physically released.</param> + internal void ReleaseKey(KeyCode id, bool waitKeyUp) + { + mKeyState[(int)id] = 0; + mWaitForKeyUp[(int)id] = waitKeyUp; + //System.Diagnostics.Debug.WriteLine("Set key {0} to {1}.", id, false); + + Input.QueueInputEvent(AgateInputEventArgs.KeyUp(id, CurrentModifiers)); + } + internal bool AnyKeyPressed + { + get + { + for (int i = 0; i < mKeyState.Length; i++) + if (mKeyState[i] > 0) + return true; + + return false; + } + } + + /// <summary> + /// Resets all keys to being in the up state (not pushed). + /// Does generate KeyUp events. + /// + /// This also makes it so any keys which were depressed must be released + /// before KeyDown events are raised again. + /// </summary> + internal void ReleaseAllKeys(bool waitForKeyUp) + { + for (int i = 0; i < mKeyState.Length; i++) + { + if (mKeyState[i] > 0) + ReleaseKey((KeyCode)i, waitForKeyUp); + } + } + + + } + + /// <summary> + /// Gets an object representing the state of all keys on the keyboard. + /// </summary> + public static KeyState Keys + { + get { return mKeyState; } + } + + /// <summary> + /// Resets all keys to being in the up state (not pushed). + /// Does generate KeyUp events. + /// + /// This also makes it so any keys which were depressed must be released + /// before KeyDown events are raised again. + /// </summary> + public static void ReleaseAllKeys() + { + mKeyState.ReleaseAllKeys(true); + } + /// <summary> + /// Resets all keys to being in the up state (not pushed). + /// Does generate KeyUp events. + /// <para> + /// This can also make it so any keys which were depressed must be released + /// before KeyDown events are raised again. + /// </para> + /// </summary> + /// <param name="waitForKeyUp">If true, then keys currently depressed will + /// not generate KeyDown events until they are released.</param> + public static void ReleaseAllKeys(bool waitForKeyUp) + { + mKeyState.ReleaseAllKeys(waitForKeyUp); + } + + /// <summary> + /// Resets a particular key to being in the up state (not pushed). + /// Generates a KeyUp event for that key. + /// <para> + /// This also makes it so that the key must be physically depressed by the user + /// before it will register a KeyDown event again. If it is already depressed, + /// it must be released first. + /// </para> + /// </summary> + /// <param name="key"></param> + public static void ReleaseKey(KeyCode key) + { + mKeyState.ReleaseKey(key, true); + } + /// <summary> + /// Resets a particular key to being in the up state (not pushed). + /// Generates a KeyUp event for that key. + /// </summary> + /// <param name="key">The key to be released.</param> + /// <param name="waitForKeyUp">If true, then keys currently depressed will + /// not generate KeyDown events until they are released.</param> + public static void ReleaseKey(KeyCode key, bool waitForKeyUp) + { + mKeyState.ReleaseKey(key, waitForKeyUp); + } + + /// <summary> + /// Checks to see if the user pressed the "Any" key. + /// </summary> + public static bool AnyKeyPressed + { + get + { + return Keys.AnyKeyPressed; + } + } + [Obsolete("Use Input.QueueInputEvent instead.", true)] + private static void OnKeyDown(KeyCode id, KeyModifiers mods, int repeatCount) + { + var eventArgs = new InputEventArgs(id, mods); + + if (AgateConsole.IsInitialized && + (AgateConsole.IsVisible || id == AgateConsole.VisibleToggleKey)) + { + AgateConsole.Keyboard_KeyDown(eventArgs); + } + else if (KeyDown != null) + KeyDown(eventArgs); + } + [Obsolete("Use Input.QueueInputEvent instead.", true)] + private static void OnKeyUp(KeyCode id, KeyModifiers mods) + { + var eventArgs = new InputEventArgs(id, mods); + + if (AgateConsole.IsVisible) + { + AgateConsole.Keyboard_KeyUp(eventArgs); + } + else if (KeyUp != null) + KeyUp(eventArgs); + } + + /// <summary> + /// Creates a string from the specified KeyCode and KeyModifiers. + /// Unfortunately this is tied to the US English keyboard, so it needs a better solution. + /// </summary> + /// <param name="keyID"></param> + /// <param name="mods"></param> + /// <returns></returns> + public static string GetKeyString(KeyCode keyID, KeyModifiers mods) + { + if ((int)keyID >= 'A' && (int)keyID <= 'Z') + { + char result; + + if (mods.Shift) + result = (char)keyID; + else + result = (char)((int)keyID + 'a' - 'A'); + + return result.ToString(); + } + + + switch (keyID) + { + case KeyCode.Tab: + return "\t"; + + case KeyCode.Return: + //case KeyCode.Enter: + return "\n"; + + case KeyCode.Space: + return " "; + + // I'd love a better way of doing this: + // likely, this is not very friendly to non US keyboard layouts. + case KeyCode.D0: + if (mods.Shift) + return ")"; + else + return "0"; + + case KeyCode.NumPad0: + return "0"; + + case KeyCode.D1: + if (mods.Shift) + return "!"; + else return "1"; + + + case KeyCode.NumPad1: + return "1"; + + case KeyCode.D2: + if (mods.Shift) + return "@"; + else return "2"; + + case KeyCode.NumPad2: + return "2"; + + case KeyCode.D3: + if (mods.Shift) + return "#"; + else return "3"; + + case KeyCode.NumPad3: + return "3"; + + case KeyCode.D4: + if (mods.Shift) + return "$"; + else return "4"; + + case KeyCode.NumPad4: + return "4"; + + case KeyCode.D5: + if (mods.Shift) + return "%"; + else return "5"; + + case KeyCode.NumPad5: + return "5"; + + case KeyCode.D6: + if (mods.Shift) + return "^"; + else return "6"; + + case KeyCode.NumPad6: + return "6"; + + case KeyCode.D7: + if (mods.Shift) + return "&"; + else return "7"; + + case KeyCode.NumPad7: + return "7"; + + case KeyCode.D8: + if (mods.Shift) + return "*"; + else return "8"; + + + case KeyCode.NumPad8: + return "8"; + + case KeyCode.D9: + if (mods.Shift) + return "("; + else return "9"; + + case KeyCode.NumPad9: + return "9"; + + case KeyCode.NumPadMinus: + return "-"; + case KeyCode.NumPadMultiply: + return "*"; + case KeyCode.NumPadPeriod: + return "."; + case KeyCode.NumPadPlus: + return "+"; + case KeyCode.NumPadSlash: + return "/"; + + case KeyCode.Semicolon: + if (mods.Shift) + return ":"; + else + return ";"; + + case KeyCode.Plus: + if (mods.Shift) + return "+"; + else + return "="; + + case KeyCode.Comma: + if (mods.Shift) + return "<"; + else + return ","; + + case KeyCode.Minus: + if (mods.Shift) + return "_"; + else + return "-"; + + case KeyCode.Period: + if (mods.Shift) + return ">"; + else + return "."; + + case KeyCode.Slash: + if (mods.Shift) + return "?"; + else + return "/"; + + case KeyCode.Tilde: + if (mods.Shift) + return "~"; + else + return "`"; + + case KeyCode.OpenBracket: + if (mods.Shift) + return "{"; + else + return "["; + + case KeyCode.BackSlash: + if (mods.Shift) + return "|"; + else + return @"\"; + + case KeyCode.CloseBracket: + if (mods.Shift) + return "}"; + else + return "]"; + + case KeyCode.Quotes: + if (mods.Shift) + return "\""; + else + return "'"; + + } + + return ""; + } + + internal static void OnKeyDown(AgateInputEventArgs args) + { + if (KeyDown != null) + KeyDown(new InputEventArgs(args)); + } + + internal static void OnKeyUp(AgateInputEventArgs args) + { + if (KeyUp != null) + KeyUp(new InputEventArgs(args)); + } + + /// <summary> + /// Event which occurs when a key is pressed. + /// </summary> + public static event InputEventHandler KeyDown; + /// <summary> + /// Event which occurs when a key is released. + /// </summary> + public static event InputEventHandler KeyUp; + + + private static void ClearEvents() + { + KeyDown = null; + KeyUp = null; + } + + } +} Added: trunk/AgateLib/InputLib/Legacy/LegacyInputHandler.cs =================================================================== --- trunk/AgateLib/InputLib/Legacy/LegacyInputHandler.cs (rev 0) +++ trunk/AgateLib/InputLib/Legacy/LegacyInputHandler.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib.Legacy +{ + class LegacyInputHandler : IInputHandler + { + public void ProcessEvent(AgateInputEventArgs args) + { + switch(args.InputEventType) + { + case InputEventType.KeyDown: Keyboard.OnKeyDown(args); break; + case InputEventType.KeyUp: Keyboard.OnKeyUp(args); break; + case InputEventType.MouseDown: Mouse.OnMouseDown(args); break; + case InputEventType.MouseUp: Mouse.OnMouseUp(args); break; + case InputEventType.MouseWheel: Mouse.OnMouseWheel(args); break; + case InputEventType.MouseMove: Mouse.OnMouseMove(args); break; + } + } + + public bool ForwardUnhandledEvents { get { return true;}} + } +} Copied: trunk/AgateLib/InputLib/Legacy/Mouse.cs (from rev 1422, trunk/AgateLib/InputLib/Mouse.cs) =================================================================== --- trunk/AgateLib/InputLib/Legacy/Mouse.cs (rev 0) +++ trunk/AgateLib/InputLib/Legacy/Mouse.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,290 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; + +using AgateLib.Geometry; + +namespace AgateLib.InputLib.Legacy +{ + using AgateLib.DisplayLib; + + /// <summary> + /// Class which encapsulates input from the mouse. The information provided by the Mouse + /// class is only accurate for applications which have a single DisplayWindow. + /// </summary> + public static class Mouse + { + /// <summary> + /// Class which encapsulates the state of the mouse. + /// </summary> + public class MouseState + { + bool[] mMouseButtons = new bool[Enum.GetValues(typeof(MouseButton)).Length]; + + internal MouseState() + { + } + + /// <summary> + /// Gets or sets the pressed values of the passed mouse buttons. + /// Generates events when buttons are pressed or released. + /// The MouseButtons enum has the FlagsAttribute, so you can make a bitwise + /// combination of these values. + /// Getting the state with a combination of flags returns true if ANY one of + /// the buttons are down. + /// Setting the state with a combination of flags will set the state for + /// all flags passed. + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public bool this[MouseButton id] + { + get + { + return mMouseButtons[(int)id]; + } + set + { + if (id == MouseButton.None) + { + mMouseButtons[(int)id] = false; + return; + } + + mMouseButtons[(int)id] = value; + + if (value == true) + Mouse.OnMouseDown(id); + else + Mouse.OnMouseUp(id); + } + } + } + + private static MouseState mState = new MouseState(); + private static bool mIsHidden = false; + private static Point mPosition; + + static Mouse() + { + Display.DisposeDisplay += new Display.DisposeDisplayHandler(Display_DisposeDisplay); + } + + static void Display_DisposeDisplay() + { + ClearEvents(); + } + + + internal static void SetStoredPosition(Point pt) + { + mPosition = pt; + + OnMouseMove(); + } + /// <summary> + /// Gets or sets the position of the cursor, in client coordinates + /// of the current display window. + /// </summary> + public static Point Position + { + get { return mPosition; } + set + { + // do not adjust the mouse position if we are not the active application. + if (Core.IsActive == false) + return; + + mPosition = value; + OnMouseMove(); + } + } + + /// <summary> + /// Gets or sets the X position of the cursor, in client coordinates + /// of the current display window. + /// </summary> + public static int X + { + get { return mPosition.X; } + set + { + mPosition.X = value; + OnMouseMove(); + } + } + /// <summary> + /// Gets or sets the Y position of the cursor, in client coordinates + /// of the current display window. + /// </summary> + public static int Y + { + get { return mPosition.Y; } + set + { + mPosition.Y = value; + OnMouseMove(); + } + } + + /// <summary> + /// Returns true if the mouse pointer is hidden. + /// </summary> + public static bool IsHidden + { + get { return mIsHidden; } + private set { mIsHidden = value; } + } + /// <summary> + /// Gets the MouseState structure which indicates which buttons + /// are pressed. + /// </summary> + public static MouseState Buttons + { + get { return mState; } + } + /// <summary> + /// Shows the OS cursor. + /// </summary> + public static void Show() + { + Display.ShowCursor(); + IsHidden = false; + } + /// <summary> + /// Hides the OS cursor. + /// </summary> + public static void Hide() + { + Display.HideCursor(); + IsHidden = true; + } + + static void ClearEvents() + { + MouseMove = null; + MouseDown = null; + MouseUp = null; + MouseDoubleClick = null; + MouseWheel = null; + } + + /// <summary> + /// Event which occurs when the mouse is moved. + /// </summary> + public static event InputEventHandler MouseMove; + /// <summary> + /// Event which occurs when a mouse button is pressed. + /// </summary> + public static event InputEventHandler MouseDown; + /// <summary> + /// Event which occurs when a mouse button is released. + /// </summary> + public static event InputEventHandler MouseUp; + /// <summary> + /// Event which occurs when a mouse button is double-clicked. + /// </summary> + public static event InputEventHandler MouseDoubleClick; + /// <summary> + /// Event which occurs when the mouse wheel is scrolled. Positive numbers + /// indicate scrolling down, while negative numbers indicate scrolling up. + /// A value of 100 means to scroll one line. + /// </summary> + public static event InputEventHandler MouseWheel; + + static bool inMouseMove = false; + + /// <summary> + /// Raises the MouseWheel event. + /// </summary> + /// <param name="delta"></param> + public static void OnMouseWheel(int delta) + { + if (MouseWheel != null) + MouseWheel(new InputEventArgs(delta)); + } + + /// <summary> + /// Raises the MouseMove event. + /// </summary> + public static void OnMouseMove() + { + if (inMouseMove) + return; + + try + { + inMouseMove = true; + + if (MouseMove != null) + MouseMove(new InputEventArgs()); + + // this is required, because if the mouse position is adjusted + // a new MouseMove event will be generated. + Core.KeepAlive(); + } + finally + { + inMouseMove = false; + } + } + private static void OnMouseDown(MouseButton btn) + { + if (MouseDown != null) + MouseDown(new InputEventArgs(btn)); + } + private static void OnMouseUp(MouseButton btn) + { + if (MouseUp != null) + MouseUp(new InputEventArgs(btn)); + } + /// <summary> + /// Raises the MouseDoubleClick event. + /// </summary> + /// <param name="btn"></param> + public static void OnMouseDoubleClick(MouseButton btn) + { + if (MouseDoubleClick != null) + MouseDoubleClick(new InputEventArgs(btn)); + } + + internal static void OnMouseDown(AgateInputEventArgs args) + { + throw new NotImplementedException(); + } + + internal static void OnMouseUp(AgateInputEventArgs args) + { + throw new NotImplementedException(); + } + + internal static void OnMouseWheel(AgateInputEventArgs args) + { + throw new NotImplementedException(); + } + + internal static void OnMouseMove(AgateInputEventArgs args) + { + throw new NotImplementedException(); + } + } + +} Deleted: trunk/AgateLib/InputLib/Mouse.cs =================================================================== --- trunk/AgateLib/InputLib/Mouse.cs 2014-07-28 14:46:21 UTC (rev 1428) +++ trunk/AgateLib/InputLib/Mouse.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -1,304 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; - -using AgateLib.Geometry; - -namespace AgateLib.InputLib -{ - using AgateLib.DisplayLib; - - /// <summary> - /// Class which encapsulates input from the mouse. The information provided by the Mouse - /// class is only accurate for applications which have a single DisplayWindow. - /// </summary> - public static class Mouse - { - /// <summary> - /// Mouse Buttons enum. - /// </summary> - public enum MouseButtons - { - /// <summary> - /// No mouse button - /// </summary> - None, - /// <summary> - /// Primary button, typically the left button. - /// </summary> - Primary, - /// <summary> - /// Secondary button, typically the right button. - /// </summary> - Secondary, - /// <summary> - /// Middle button on some mice. - /// </summary> - Middle, - /// <summary> - /// First Extra Button - /// </summary> - ExtraButton1, - /// <summary> - /// Second Extra Button - /// </summary> - ExtraButton2, - /// <summary> - /// Third Extra Button - /// </summary> - ExtraButton3, - } - - /// <summary> - /// Class which encapsulates the state of the mouse. - /// </summary> - public class MouseState - { - bool[] mMouseButtons = new bool[Enum.GetValues(typeof(MouseButtons)).Length]; - - internal MouseState() - { - } - - /// <summary> - /// Gets or sets the pressed values of the passed mouse buttons. - /// Generates events when buttons are pressed or released. - /// The MouseButtons enum has the FlagsAttribute, so you can make a bitwise - /// combination of these values. - /// Getting the state with a combination of flags returns true if ANY one of - /// the buttons are down. - /// Setting the state with a combination of flags will set the state for - /// all flags passed. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public bool this[MouseButtons id] - { - get - { - return mMouseButtons[(int)id]; - } - set - { - if (id == MouseButtons.None) - { - mMouseButtons[(int)id] = false; - return; - } - - mMouseButtons[(int)id] = value; - - if (value == true) - Mouse.OnMouseDown(id); - else - Mouse.OnMouseUp(id); - } - } - } - - private static MouseState mState = new MouseState(); - private static bool mIsHidden = false; - private static Point mPosition; - - static Mouse() - { - Display.DisposeDisplay += new Display.DisposeDisplayHandler(Display_DisposeDisplay); - } - - static void Display_DisposeDisplay() - { - ClearEvents(); - } - - - internal static void SetStoredPosition(Point pt) - { - mPosition = pt; - - OnMouseMove(); - } - /// <summary> - /// Gets or sets the position of the cursor, in client coordinates - /// of the current display window. - /// </summary> - public static Point Position - { - get { return mPosition; } - set - { - // do not adjust the mouse position if we are not the active application. - if (Core.IsActive == false) - return; - - mPosition = value; - OnMouseMove(); - } - } - - /// <summary> - /// Gets or sets the X position of the cursor, in client coordinates - /// of the current display window. - /// </summary> - public static int X - { - get { return mPosition.X; } - set - { - mPosition.X = value; - OnMouseMove(); - } - } - /// <summary> - /// Gets or sets the Y position of the cursor, in client coordinates - /// of the current display window. - /// </summary> - public static int Y - { - get { return mPosition.Y; } - set - { - mPosition.Y = value; - OnMouseMove(); - } - } - - /// <summary> - /// Returns true if the mouse pointer is hidden. - /// </summary> - public static bool IsHidden - { - get { return mIsHidden; } - private set { mIsHidden = value; } - } - /// <summary> - /// Gets the MouseState structure which indicates which buttons - /// are pressed. - /// </summary> - public static MouseState Buttons - { - get { return mState; } - } - /// <summary> - /// Shows the OS cursor. - /// </summary> - public static void Show() - { - Display.ShowCursor(); - IsHidden = false; - } - /// <summary> - /// Hides the OS cursor. - /// </summary> - public static void Hide() - { - Display.HideCursor(); - IsHidden = true; - } - - static void ClearEvents() - { - MouseMove = null; - MouseDown = null; - MouseUp = null; - MouseDoubleClick = null; - MouseWheel = null; - } - - /// <summary> - /// Event which occurs when the mouse is moved. - /// </summary> - public static event InputEventHandler MouseMove; - /// <summary> - /// Event which occurs when a mouse button is pressed. - /// </summary> - public static event InputEventHandler MouseDown; - /// <summary> - /// Event which occurs when a mouse button is released. - /// </summary> - public static event InputEventHandler MouseUp; - /// <summary> - /// Event which occurs when a mouse button is double-clicked. - /// </summary> - public static event InputEventHandler MouseDoubleClick; - /// <summary> - /// Event which occurs when the mouse wheel is scrolled. Positive numbers - /// indicate scrolling down, while negative numbers indicate scrolling up. - /// A value of 100 means to scroll one line. - /// </summary> - public static event InputEventHandler MouseWheel; - - static bool inMouseMove = false; - - /// <summary> - /// Raises the MouseWheel event. - /// </summary> - /// <param name="delta"></param> - public static void OnMouseWheel(int delta) - { - if (MouseWheel != null) - MouseWheel(new InputEventArgs(delta)); - } - - /// <summary> - /// Raises the MouseMove event. - /// </summary> - public static void OnMouseMove() - { - if (inMouseMove) - return; - - try - { - inMouseMove = true; - - if (MouseMove != null) - MouseMove(new InputEventArgs()); - - // this is required, because if the mouse position is adjusted - // a new MouseMove event will be generated. - Core.KeepAlive(); - } - finally - { - inMouseMove = false; - } - } - private static void OnMouseDown(MouseButtons btn) - { - if (MouseDown != null) - MouseDown(new InputEventArgs(btn)); - } - private static void OnMouseUp(MouseButtons btn) - { - if (MouseUp != null) - MouseUp(new InputEventArgs(btn)); - } - /// <summary> - /// Raises the MouseDoubleClick event. - /// </summary> - /// <param name="btn"></param> - public static void OnMouseDoubleClick(MouseButtons btn) - { - if (MouseDoubleClick != null) - MouseDoubleClick(new InputEventArgs(btn)); - } - } -} Added: trunk/AgateLib/InputLib/MouseButton.cs =================================================================== --- trunk/AgateLib/InputLib/MouseButton.cs (rev 0) +++ trunk/AgateLib/InputLib/MouseButton.cs 2014-08-02 00:49:42 UTC (rev 1429) @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib +{ + + /// <summary> + /// Mouse Buttons enum. + /// </summary> + public enum MouseButton + { + /// <summary> + /// No mouse button + /// </summary> + None, + /// <summary> + /// Primary button, typically the left button. + /// </summary> + Primary, + /// <summary> + /// Secondary button, typically the ... [truncated message content] |
From: <ka...@us...> - 2014-07-28 14:46:24
|
Revision: 1428 http://sourceforge.net/p/agate/code/1428 Author: kanato Date: 2014-07-28 14:46:21 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Modify initialization of AgateAppModel so it happens a little later, and fix associated unit test. Modified Paths: -------------- trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 05:16:44 UTC (rev 1427) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 14:46:21 UTC (rev 1428) @@ -48,11 +48,17 @@ throw new AgateException("Cannot create a new application model when an existing one is active."); Instance = this; + } + public void Initialize() + { + ProcessArguments(); - ProcessArguments(); + InitializeImpl(); } - public abstract void Initialize(); + protected virtual void InitializeImpl() + { } + public void Dispose() { Dispose(true); Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs 2014-07-28 05:16:44 UTC (rev 1427) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs 2014-07-28 14:46:21 UTC (rev 1428) @@ -16,7 +16,7 @@ } - public override void Initialize() + protected override void InitializeImpl() { Configuration.Initialize(); } Modified: trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs =================================================================== --- trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs 2014-07-28 05:16:44 UTC (rev 1427) +++ trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs 2014-07-28 14:46:21 UTC (rev 1428) @@ -11,6 +11,8 @@ { public class ArgumentProcessing : AgateAppModel { + List<string> expected = new List<string>(); + public ArgumentProcessing(ModelParameters param) : base(param) { @@ -21,16 +23,33 @@ return 0; } - protected override void Initialize() + public List<string> Expected { get { return expected; } } + + protected override void InitializeImpl() { } - protected override void Dispose() + public override void KeepAlive() { } - public override void KeepAlive() + protected override void ProcessArgument(string arg, string parm) { + if (Expected.Count > 0) + { + Assert.AreEqual(expected[0], arg); + Assert.IsTrue(arg.StartsWith("--")); + + expected.RemoveAt(0); + + if (parm != "") + { + Assert.AreEqual(expected[0], parm); + expected.RemoveAt(0); + } + } + + base.ProcessArgument(arg, parm); } } @@ -46,8 +65,32 @@ "--window 640x480".Split(' ') }); + p.Initialize(); + Assert.IsFalse(p.Parameters.CreateFullScreenWindow); Assert.AreEqual(new Size(640, 480), p.Parameters.DisplayWindowSize); } + + [TestMethod] + public void ExtraArguments() + { + ArgumentProcessing p = new ArgumentProcessing(new ModelParameters + { + Arguments = + "--window 640x480 --something --else 14 --nothing".Split(' ') + }); + + p.Expected.Add("--window"); + p.Expected.Add("640x480"); + p.Expected.Add("--something"); + p.Expected.Add("--else"); + p.Expected.Add("14"); + p.Expected.Add("--nothing"); + + p.Initialize(); + + Assert.IsFalse(p.Parameters.CreateFullScreenWindow); + Assert.AreEqual(new Size(640, 480), p.Parameters.DisplayWindowSize); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-28 05:16:51
|
Revision: 1427 http://sourceforge.net/p/agate/code/1427 Author: kanato Date: 2014-07-28 05:16:44 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Make Initialize/Dispose methods of application models publically accessible. Modified Paths: -------------- trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 04:35:48 UTC (rev 1426) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 05:16:44 UTC (rev 1427) @@ -7,7 +7,7 @@ namespace AgateLib.ApplicationModels { - public abstract class AgateAppModel + public abstract class AgateAppModel : IDisposable { #region --- Static Members --- @@ -51,7 +51,19 @@ ProcessArguments(); } + public abstract void Initialize(); + public void Dispose() + { + Dispose(true); + + if (Instance == this) + Instance = null; + } + protected virtual void Dispose(bool disposing) + { } + + public int Run(Action entry) { return RunImpl(entry); @@ -205,9 +217,6 @@ return Display.Caps.NativeScreenResolution; } - protected abstract void Initialize(); - protected abstract void Dispose(); - protected DisplayWindow AutoCreatedWindow { get { return window; } } public ModelParameters Parameters { get; set; } Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs 2014-07-28 04:35:48 UTC (rev 1426) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs 2014-07-28 05:16:44 UTC (rev 1427) @@ -16,13 +16,12 @@ } - protected override void Initialize() + public override void Initialize() { Configuration.Initialize(); } - protected override void Dispose() + protected override void Dispose(bool disposing) { - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-28 04:35:51
|
Revision: 1426 http://sourceforge.net/p/agate/code/1426 Author: kanato Date: 2014-07-28 04:35:48 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Move database stuff to AgateLib.Platform.WindowsForms. Modified Paths: -------------- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabaseException.cs trunk/AgateLib.Platform.WindowsForms/PixelBufferExtensions.cs trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs trunk/AgateLib.Platform.WindowsForms/WinForms/FormsInterop.cs trunk/Tools/AgateDataLib/AgateDataLib.csproj trunk/Tools/DatabaseEditor/DatabaseEditor.csproj Added Paths: ----------- trunk/AgateLib.Platform.WindowsForms/Data/ Removed Paths: ------------- trunk/AgateLib/Data/ Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-28 04:12:11 UTC (rev 1425) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-28 04:35:48 UTC (rev 1426) @@ -75,6 +75,16 @@ <Compile Include="ApplicationModels\SceneModel.cs" /> <Compile Include="ApplicationModels\SerialModel.cs" /> <Compile Include="ApplicationModels\SerialModelParameters.cs" /> + <Compile Include="Data\AgateColumn.cs" /> + <Compile Include="Data\AgateColumnDictionary.cs" /> + <Compile Include="Data\AgateDatabase.cs" /> + <Compile Include="Data\AgateDatabaseException.cs" /> + <Compile Include="Data\AgateDataHelper.cs" /> + <Compile Include="Data\AgateRow.cs" /> + <Compile Include="Data\AgateRowList.cs" /> + <Compile Include="Data\AgateTable.cs" /> + <Compile Include="Data\AgateTableDictionary.cs" /> + <Compile Include="Data\FieldType.cs" /> <Compile Include="Diagnostics\AgateConsoleImpl.cs" /> <Compile Include="Diagnostics\AgateConsoleTraceListener.cs" /> <Compile Include="DisplayImplementation\frmFullScreen.cs"> Modified: trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabaseException.cs =================================================================== --- trunk/AgateLib/Data/AgateDatabaseException.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/AgateLib.Platform.WindowsForms/Data/AgateDatabaseException.cs 2014-07-28 04:35:48 UTC (rev 1426) @@ -26,7 +26,6 @@ /// <summary> /// Exception which is thrown if there is an error when working with the database. /// </summary> - [global::System.Serializable] public class AgateDatabaseException : AgateException { // Modified: trunk/AgateLib.Platform.WindowsForms/PixelBufferExtensions.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PixelBufferExtensions.cs 2014-07-28 04:12:11 UTC (rev 1425) +++ trunk/AgateLib.Platform.WindowsForms/PixelBufferExtensions.cs 2014-07-28 04:35:48 UTC (rev 1426) @@ -1,4 +1,5 @@ using AgateLib.DisplayLib; +using AgateLib.Platform.WindowsForms.WinForms; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +12,33 @@ public static class PixelBufferExtensions { /// <summary> + /// Converts an AgateLib.DisplayLib.PixelBuffer object into a System.Drawing.Bitmap object. + /// </summary> + /// <param name="buffer">The PixelBuffer object containing the pixel data.</param> + /// <returns></returns> + public static System.Drawing.Bitmap ToBitmap(this PixelBuffer buffer) + { + System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(buffer.Width, buffer.Height); + + System.Drawing.Imaging.BitmapData data = bmp.LockBits( + new System.Drawing.Rectangle(System.Drawing.Point.Empty, Interop.Convert(buffer.Size)), + System.Drawing.Imaging.ImageLockMode.WriteOnly, + System.Drawing.Imaging.PixelFormat.Format32bppArgb); + + if (buffer.PixelFormat != PixelFormat.BGRA8888) + { + buffer = buffer.ConvertTo(PixelFormat.BGRA8888); + } + + System.Runtime.InteropServices.Marshal.Copy( + buffer.Data, 0, data.Scan0, buffer.Data.Length); + + bmp.UnlockBits(data); + + return bmp; + } + + /// <summary> /// Copies the data from the unmanaged memory pointer passed in into the internal pixel /// buffer array. Automatic conversion is performed if the format the data /// is in (indicated by format parameter) differs from the format the Modified: trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs 2014-07-28 04:12:11 UTC (rev 1425) +++ trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs 2014-07-28 04:35:48 UTC (rev 1426) @@ -179,7 +179,7 @@ /// <param name="format"></param> public static void SavePixelBuffer(PixelBuffer buffer, string filename, ImageFileFormat format) { - Bitmap bmp = Interop.BitmapFromPixelBuffer(buffer); + Bitmap bmp = buffer.ToBitmap(); var dirname = Path.GetDirectoryName(filename); if (string.IsNullOrEmpty(dirname) == false && Directory.Exists(dirname) == false) Modified: trunk/AgateLib.Platform.WindowsForms/WinForms/FormsInterop.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/WinForms/FormsInterop.cs 2014-07-28 04:12:11 UTC (rev 1425) +++ trunk/AgateLib.Platform.WindowsForms/WinForms/FormsInterop.cs 2014-07-28 04:35:48 UTC (rev 1426) @@ -191,31 +191,5 @@ return new Draw.SizeF(sz.Width, sz.Height); } - /// <summary> - /// Converts an AgateLib.DisplayLib.PixelBuffer object into a System.Drawing.Bitmap object. - /// </summary> - /// <param name="buffer">The PixelBuffer object containing the pixel data.</param> - /// <returns></returns> - public static System.Drawing.Bitmap BitmapFromPixelBuffer(PixelBuffer buffer) - { - System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(buffer.Width, buffer.Height); - - System.Drawing.Imaging.BitmapData data = bmp.LockBits( - new Draw.Rectangle(Draw.Point.Empty, Interop.Convert(buffer.Size)), - System.Drawing.Imaging.ImageLockMode.WriteOnly, - System.Drawing.Imaging.PixelFormat.Format32bppArgb); - - if (buffer.PixelFormat != PixelFormat.BGRA8888) - { - buffer = buffer.ConvertTo(PixelFormat.BGRA8888); - } - - System.Runtime.InteropServices.Marshal.Copy( - buffer.Data, 0, data.Scan0, buffer.Data.Length); - - bmp.UnlockBits(data); - - return bmp; - } } } Modified: trunk/Tools/AgateDataLib/AgateDataLib.csproj =================================================================== --- trunk/Tools/AgateDataLib/AgateDataLib.csproj 2014-07-28 04:12:11 UTC (rev 1425) +++ trunk/Tools/AgateDataLib/AgateDataLib.csproj 2014-07-28 04:35:48 UTC (rev 1426) @@ -99,6 +99,10 @@ <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> <Name>AgateLib</Name> Modified: trunk/Tools/DatabaseEditor/DatabaseEditor.csproj =================================================================== --- trunk/Tools/DatabaseEditor/DatabaseEditor.csproj 2014-07-28 04:12:11 UTC (rev 1425) +++ trunk/Tools/DatabaseEditor/DatabaseEditor.csproj 2014-07-28 04:35:48 UTC (rev 1426) @@ -183,10 +183,18 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> <Name>AgateLib</Name> </ProjectReference> + <ProjectReference Include="..\AgateDataLib\AgateDataLib.csproj"> + <Project>{2f7a686b-2272-4803-9ef9-0b34ba7802dc}</Project> + <Name>AgateDataLib</Name> + </ProjectReference> <ProjectReference Include="..\NotebookLib\NotebookLib\NotebookLib.csproj"> <Project>{91F57346-B574-4D52-9EB0-AA191B552C94}</Project> <Name>NotebookLib</Name> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-28 04:12:25
|
Revision: 1425 http://sourceforge.net/p/agate/code/1425 Author: kanato Date: 2014-07-28 04:12:11 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Fix examples compiling. Modified Paths: -------------- trunk/Examples/ShootTheTraps/App.cs trunk/Examples.sln Modified: trunk/Examples/ShootTheTraps/App.cs =================================================================== --- trunk/Examples/ShootTheTraps/App.cs 2014-07-28 04:05:34 UTC (rev 1424) +++ trunk/Examples/ShootTheTraps/App.cs 2014-07-28 04:12:11 UTC (rev 1425) @@ -8,6 +8,7 @@ using AgateLib.InputLib; using AgateLib.Platform.WindowsForms.Resources; using AgateLib.Platform; +using AgateLib.Platform.WindowsForms.ApplicationModels; namespace ShootTheTraps { @@ -19,7 +20,7 @@ [STAThread] static void Main(string[] args) { - new App().Run(args); + new PassiveModel(args).Run(() => new App().Run(args)); } // Game declarations Modified: trunk/Examples.sln =================================================================== --- trunk/Examples.sln 2014-07-28 04:05:34 UTC (rev 1424) +++ trunk/Examples.sln 2014-07-28 04:12:11 UTC (rev 1425) @@ -1,26 +1,22 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BallBuster.Net", "Examples\BallBuster.Net\BallBuster.Net.csproj", "{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShootTheTraps", "Examples\ShootTheTraps\ShootTheTraps.csproj", "{50743D1B-A19E-42F1-842F-65FAD6D168C3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pong", "Examples\Pong\Pong.csproj", "{436641C4-846C-42D0-8E8F-95F70E211D22}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateDrawing", "Drivers\AgateDrawing\AgateDrawing.csproj", "{164A785D-924E-40FB-A517-D7E677F3B53A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateOTK", "Drivers\AgateOTK\AgateOTK.csproj", "{9E095F03-BA3F-4EAD-A905-2A2647CE4405}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib", "AgateLib\AgateLib.csproj", "{9490B719-829E-43A7-A5FE-8001F8A81759}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.WinForms", "Drivers\AgateLib.WinForms\AgateLib.WinForms.csproj", "{BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleUnitTests", "Examples\ExampleUnitTests\ExampleUnitTests.csproj", "{8299274E-05DD-49E0-ACB8-70C2BBAC69D1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDL", "Drivers\AgateSDL\AgateSDL.csproj", "{00C7FA95-98F4-43D9-9B63-34122B1DB003}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.GL", "AgateLib.GL\AgateLib.GL.csproj", "{94734E5A-0344-43E8-BB30-E32E3F57F611}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleUnitTests", "Examples\ExampleUnitTests\ExampleUnitTests.csproj", "{8299274E-05DD-49E0-ACB8-70C2BBAC69D1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.Platform.WindowsForms", "AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj", "{4B12561E-D37B-48A1-B6DB-218E94906C22}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDX", "Drivers\AgateSDX\AgateSDX.csproj", "{EF993B30-D9A9-4962-80BB-6826D39B3465}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,86 +77,20 @@ {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|x64.Build.0 = Release|x64 {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|x86.ActiveCfg = Release|x86 {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|x86.Build.0 = Release|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|x64.ActiveCfg = Debug|x64 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|x64.Build.0 = Debug|x64 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|x86.ActiveCfg = Debug|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|x86.Build.0 = Debug|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|Any CPU.Build.0 = Release|Any CPU - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|Mixed Platforms.Build.0 = Release|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|x64.ActiveCfg = Release|x64 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|x64.Build.0 = Release|x64 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|x86.ActiveCfg = Release|x86 - {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|x86.Build.0 = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|x64.ActiveCfg = Debug|x64 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|x64.Build.0 = Debug|x64 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|x86.ActiveCfg = Debug|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|x86.Build.0 = Debug|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Any CPU.Build.0 = Release|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Mixed Platforms.Build.0 = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|x64.ActiveCfg = Release|x64 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|x64.Build.0 = Release|x64 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|x86.ActiveCfg = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|x86.Build.0 = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.Build.0 = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x64.ActiveCfg = Debug|x64 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x64.Build.0 = Debug|x64 + {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x64.ActiveCfg = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x86.ActiveCfg = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x86.Build.0 = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Any CPU.ActiveCfg = Release|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Any CPU.Build.0 = Release|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Mixed Platforms.ActiveCfg = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Mixed Platforms.Build.0 = Release|x86 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x64.ActiveCfg = Release|x64 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x64.Build.0 = Release|x64 + {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x64.ActiveCfg = Release|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x86.ActiveCfg = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x86.Build.0 = Release|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|x64.ActiveCfg = Debug|x64 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|x64.Build.0 = Debug|x64 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|x86.ActiveCfg = Debug|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|x86.Build.0 = Debug|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|Any CPU.Build.0 = Release|Any CPU - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|Mixed Platforms.Build.0 = Release|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|x64.ActiveCfg = Release|x64 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|x64.Build.0 = Release|x64 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|x86.ActiveCfg = Release|x86 - {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|x86.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x64.ActiveCfg = Debug|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x64.Build.0 = Debug|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x86.ActiveCfg = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x86.Build.0 = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.Build.0 = Release|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Mixed Platforms.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x64.ActiveCfg = Release|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x64.Build.0 = Release|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x86.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x86.Build.0 = Release|x86 {8299274E-05DD-49E0-ACB8-70C2BBAC69D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8299274E-05DD-49E0-ACB8-70C2BBAC69D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8299274E-05DD-49E0-ACB8-70C2BBAC69D1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -173,27 +103,36 @@ {8299274E-05DD-49E0-ACB8-70C2BBAC69D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8299274E-05DD-49E0-ACB8-70C2BBAC69D1}.Release|x64.ActiveCfg = Release|Any CPU {8299274E-05DD-49E0-ACB8-70C2BBAC69D1}.Release|x86.ActiveCfg = Release|Any CPU - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|x64.ActiveCfg = Debug|x64 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|x64.Build.0 = Debug|x64 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|x86.ActiveCfg = Debug|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Debug|x86.Build.0 = Debug|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|Any CPU.Build.0 = Release|Any CPU - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|Mixed Platforms.Build.0 = Release|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|x64.ActiveCfg = Release|x64 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|x64.Build.0 = Release|x64 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|x86.ActiveCfg = Release|x86 - {EF993B30-D9A9-4962-80BB-6826D39B3465}.Release|x86.Build.0 = Release|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|x64.ActiveCfg = Debug|Any CPU + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|x86.ActiveCfg = Debug|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|x86.Build.0 = Debug|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|Any CPU.Build.0 = Release|Any CPU + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|Mixed Platforms.Build.0 = Release|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|x64.ActiveCfg = Release|Any CPU + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|x86.ActiveCfg = Release|x86 + {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|x86.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|x64.ActiveCfg = Debug|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|x86.ActiveCfg = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|x86.Build.0 = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Any CPU.Build.0 = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Mixed Platforms.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x64.ActiveCfg = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x86.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection EndGlobal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-28 04:05:37
|
Revision: 1424 http://sourceforge.net/p/agate/code/1424 Author: kanato Date: 2014-07-28 04:05:34 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Some event processing cleanup. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib/Core.cs trunk/AgateLib/DisplayLib/Display.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SceneModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs trunk/Tests/Tests.csproj trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs trunk/UnitTests/Fakes/FakeDisplayDriver.cs Added Paths: ----------- trunk/AgateLib/ApplicationModels/ExitGameException.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib/AgateLib.csproj 2014-07-28 04:05:34 UTC (rev 1424) @@ -108,6 +108,7 @@ <Compile Include="Drivers\IInputFactory.cs" /> <Compile Include="Drivers\IPlatformFactory.cs" /> <Compile Include="Drivers\TypeRegistry.cs" /> + <Compile Include="ApplicationModels\ExitGameException.cs" /> <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> <Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" /> Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -79,7 +79,14 @@ } protected virtual int RunImpl(Func<int> entry) { - return RunModel(entry); + try + { + return RunModel(entry); + } + catch (ExitGameException) + { + return 0; + } } protected virtual void ProcessArguments() @@ -204,5 +211,7 @@ protected DisplayWindow AutoCreatedWindow { get { return window; } } public ModelParameters Parameters { get; set; } + + public abstract void KeepAlive(); } } Added: trunk/AgateLib/ApplicationModels/ExitGameException.cs =================================================================== --- trunk/AgateLib/ApplicationModels/ExitGameException.cs (rev 0) +++ trunk/AgateLib/ApplicationModels/ExitGameException.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.ApplicationModels +{ + public class ExitGameException : Exception + { + public ExitGameException() { } + public ExitGameException(string message) : base(message) { } + public ExitGameException(string message, Exception inner) : base(message, inner) { } + } +} Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib/Core.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -30,6 +30,7 @@ using AgateLib.Diagnostics; using AgateLib.IO; using AgateLib.InputLib; +using AgateLib.ApplicationModels; namespace AgateLib { @@ -394,12 +395,14 @@ /// <summary> /// Delegate for types which attach to the KeepAliveEvent. /// </summary> + [Obsolete("This type is obsoleted by the Action delegate.", true)] public delegate void KeepAliveDelegate(); /// <summary> /// Event which occurs when KeepAlive is called. /// This allows subsystems (such as GUI, Input, Sound) to make updates each frame. /// </summary> - public static event KeepAliveDelegate KeepAliveEvent; + [Obsolete("This is not relevant in the new application models.", true)] + public static event Action KeepAliveEvent; /// <summary> /// Plays nice with the OS, by allowing events to be handled. /// This also handles user input events associated with the application, @@ -407,34 +410,22 @@ /// </summary> public static void KeepAlive() { - // Some tests indicate that using the Win32 platform-specific call - // to PeekMessage before calling DoEvents is about 1 fps faster, - // when there are no events to process. It's not clear whether or - // not this is worth it when there lots of events being generated - // (ie lots of mouse move events) but it does seem to speed up for - // Direct3D. - if (Display.IsAppIdle == false) + var appmodel = AgateAppModel.Instance; + + appmodel.KeepAlive(); + + while (IsActive == false && AutoPause) { - Display.ProcessEvents(); + appmodel.KeepAlive(); - while (IsActive == false && AutoPause) - { - //System.Threading.Thread.Sleep(25); - Display.ProcessEvents(); + AudioLib.Audio.Update(); - // Update Audio Engine, if necessary - AudioLib.Audio.Update(); - - if (Display.CurrentWindow == null) - break; - else if (Display.CurrentWindow.IsClosed) - break; - } + if (Display.CurrentWindow == null) + break; + else if (Display.CurrentWindow.IsClosed) + break; } - if (KeepAliveEvent != null) - KeepAliveEvent(); - // Update Audio Engine. AudioLib.Audio.Update(); Modified: trunk/AgateLib/DisplayLib/Display.cs =================================================================== --- trunk/AgateLib/DisplayLib/Display.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib/DisplayLib/Display.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -123,13 +123,6 @@ Shaders.AgateBuiltInShaders.DisposeShaders(); } - internal static void ProcessEvents() - { - if (sImpl == null) - return; - - sImpl.ProcessEvents(); - } internal static bool IsAppIdle { get Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -622,11 +622,6 @@ { } /// <summary> - /// Processes pending events. - /// </summary> - protected internal abstract void ProcessEvents(); - - /// <summary> /// Returns true if the application is idle and processing of events can be skipped. /// Base method just returns false to force processing of events at every frame. /// </summary> Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -7,6 +7,11 @@ namespace AgateLib.Platform.WindowsForms.ApplicationModels { + /// <summary> + /// The passive model does very little - it simply initializes AgateLib and cleans up when your + /// program exits. The passive model is suitable for applications which provide their own message + /// pump and render loop logic. + /// </summary> public class PassiveModel : FormsModelBase { #region --- Static Members --- @@ -45,5 +50,10 @@ return entryPoint(); } + + public override void KeepAlive() + { + System.Windows.Forms.Application.DoEvents(); + } } } Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SceneModel.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SceneModel.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SceneModel.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -18,5 +18,10 @@ { throw new NotImplementedException(); } + + public override void KeepAlive() + { + throw new NotImplementedException(); + } } } Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -41,8 +41,6 @@ get { return (SerialModelParameters)base.Parameters; } } - bool done = false; - int ExecuteEntry(Func<int> entryPoint) { try @@ -52,7 +50,14 @@ window.ReinitializeFramebuffer(); - return entryPoint(); + try + { + return entryPoint(); + } + catch(ExitGameException) + { + return 0; + } } finally { @@ -73,5 +78,9 @@ return retval; } + + public override void KeepAlive() + { + } } } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -69,14 +69,6 @@ private set { mNonPowerOf2Textures = value; } } - internal event EventHandler ProcessEventsEvent; - - protected override void ProcessEvents() - { - if (ProcessEventsEvent != null) - ProcessEventsEvent(this, EventArgs.Empty); - } - protected override void OnRenderTargetChange(FrameBuffer oldRenderTarget) { mRenderTarget = RenderTarget.Impl as GL_FrameBuffer; Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -122,16 +122,9 @@ mDisplay = Display.Impl as DesktopGLDisplay; } - mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent); mDisplay.InitializeCurrentContext(); - } - void mDisplay_ProcessEventsEvent(object sender, EventArgs e) - { - System.Windows.Forms.Application.DoEvents(); - } - private void CreateFullScreenDisplay() { DetachEvents(); @@ -365,8 +358,6 @@ public override void Dispose() { - mDisplay.ProcessEventsEvent -= mDisplay_ProcessEventsEvent; - if (mFrameBuffer != null) { mFrameBuffer.Dispose(); Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -206,8 +206,6 @@ mDisplay = Display.Impl as DesktopGLDisplay; - mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent); - mDisplay.InitializeCurrentContext(); mDrawBuffer = mDisplay.CreateDrawBuffer(); @@ -361,6 +359,7 @@ } Point lastMouse; + [Obsolete] void mDisplay_ProcessEventsEvent(object sender, EventArgs e) { try @@ -393,8 +392,6 @@ mWindow.Dispose(); mWindow = null; } - - mDisplay.ProcessEventsEvent -= mDisplay_ProcessEventsEvent; } public override bool IsClosed Modified: trunk/Tests/Tests.csproj =================================================================== --- trunk/Tests/Tests.csproj 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/Tests/Tests.csproj 2014-07-28 04:05:34 UTC (rev 1424) @@ -549,6 +549,10 @@ <WCFMetadata Include="Service References\" /> </ItemGroup> <ItemGroup> + <Folder Include="CoreTests\Performance\" /> + <Folder Include="ResourceTests\" /> + </ItemGroup> + <ItemGroup> <ProjectReference Include="..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> <Name>AgateLib.Platform.WindowsForms</Name> @@ -558,10 +562,6 @@ <Name>AgateLib</Name> </ProjectReference> </ItemGroup> - <ItemGroup> - <Folder Include="CoreTests\Performance\" /> - <Folder Include="ResourceTests\" /> - </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PreBuildEvent> Modified: trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs =================================================================== --- trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -9,9 +9,10 @@ namespace AgateLib.UnitTests.ApplicationModels { - public class ArgumentProcessing : AgateAppModel + public class ArgumentProcessing : AgateAppModel { - public ArgumentProcessing(ModelParameters param) : base(param) + public ArgumentProcessing(ModelParameters param) + : base(param) { } @@ -27,6 +28,10 @@ protected override void Dispose() { } + + public override void KeepAlive() + { + } } [TestClass] Modified: trunk/UnitTests/Fakes/FakeDisplayDriver.cs =================================================================== --- trunk/UnitTests/Fakes/FakeDisplayDriver.cs 2014-07-28 03:13:49 UTC (rev 1423) +++ trunk/UnitTests/Fakes/FakeDisplayDriver.cs 2014-07-28 04:05:34 UTC (rev 1424) @@ -142,11 +142,6 @@ throw new NotImplementedException(); } - protected internal override void ProcessEvents() - { - throw new NotImplementedException(); - } - protected internal override void ShowCursor() { throw new NotImplementedException(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-28 03:13:57
|
Revision: 1423 http://sourceforge.net/p/agate/code/1423 Author: kanato Date: 2014-07-28 03:13:49 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Fix serial model to allow exiting. Modified Paths: -------------- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs trunk/Examples/BallBuster.Net/Program.cs trunk/Examples/Pong/Pong.cs trunk/Tools/FontCreator/FontCreatorProgram.cs trunk/Tools/PackedSpriteCreator/SpritePacker.cs Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -41,15 +41,26 @@ get { return (SerialModelParameters)base.Parameters; } } + bool done = false; + int ExecuteEntry(Func<int> entryPoint) { - OpenTK.Graphics.GraphicsContext.ShareContexts = true; - var window = AutoCreatedWindow.Impl as IPrimaryWindow; + try + { + OpenTK.Graphics.GraphicsContext.ShareContexts = true; + var window = AutoCreatedWindow.Impl as IPrimaryWindow; - window.ReinitializeFramebuffer(); + window.ReinitializeFramebuffer(); - return entryPoint(); + return entryPoint(); + } + finally + { + var primaryWindow = AutoCreatedWindow.Impl as IPrimaryWindow; + primaryWindow.ExitMessageLoop(); + } } + protected override int BeginModel(Func<int> entryPoint) { int retval = 0; @@ -57,7 +68,6 @@ thread.Start(); var primaryWindow = AutoCreatedWindow.Impl as IPrimaryWindow; - primaryWindow.RunApplication(); return retval; Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -615,5 +615,11 @@ { Application.Run(frm); } + + + public void ExitMessageLoop() + { + Application.Exit(); + } } } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -523,5 +523,11 @@ { CreateFrameBuffer(); } + + + public void ExitMessageLoop() + { + mWindow.Exit(); + } } } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -6,5 +6,7 @@ void RunApplication(); void ReinitializeFramebuffer(); + + void ExitMessageLoop(); } } Modified: trunk/Examples/BallBuster.Net/Program.cs =================================================================== --- trunk/Examples/BallBuster.Net/Program.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/Examples/BallBuster.Net/Program.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -31,7 +31,7 @@ [STAThread] static void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run(() => { BBX bbx = new BBX(); Modified: trunk/Examples/Pong/Pong.cs =================================================================== --- trunk/Examples/Pong/Pong.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/Examples/Pong/Pong.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -6,6 +6,7 @@ using AgateLib.InputLib; using AgateLib.Platform.WindowsForms.ApplicationModels; using AgateLib.Platform.WindowsForms.Resources; +using AgateLib.ApplicationModels; namespace Pong { @@ -18,7 +19,11 @@ [STAThread] static void Main(string[] args) { - PassiveModel.Run(args, () => + new SerialModel(new SerialModelParameters + { + Arguments = args, + ApplicationName = "Pong Example", + }).Run(() => { new Program().Run(args); }); @@ -45,9 +50,6 @@ void Run(string[] args) { - DisplayWindow wind = DisplayWindow.CreateWindowed - ("Pong Example", displayWidth, displayHeight); - font = BuiltinResources.AgateSans14; paddle[0] = new Vector2(50, displayHeight / 2); @@ -55,11 +57,11 @@ ball = new Vector2(playAreaWidth / 2, displayHeight / 2); ballvelocity = new Vector2(-70, 70); - while (wind.IsClosed == false) + while (AgateAppModel.IsAlive) { Display.BeginFrame(); Display.Clear(Color.DarkGray); - + DrawBorder(); DrawPaddles(); DrawBall(); @@ -69,7 +71,7 @@ Core.KeepAlive(); if (Keyboard.Keys[KeyCode.Escape]) - wind.Dispose(); + return; float time_s = (float)Display.DeltaTime / 1000.0f; Modified: trunk/Tools/FontCreator/FontCreatorProgram.cs =================================================================== --- trunk/Tools/FontCreator/FontCreatorProgram.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/Tools/FontCreator/FontCreatorProgram.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -20,7 +20,7 @@ Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - PassiveModel.Run(args, () => + new PassiveModel(args).Run(() => { Directory.CreateDirectory("./images"); Modified: trunk/Tools/PackedSpriteCreator/SpritePacker.cs =================================================================== --- trunk/Tools/PackedSpriteCreator/SpritePacker.cs 2014-07-28 02:55:51 UTC (rev 1422) +++ trunk/Tools/PackedSpriteCreator/SpritePacker.cs 2014-07-28 03:13:49 UTC (rev 1423) @@ -16,7 +16,7 @@ [STAThread] static void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run(() => { System.Windows.Forms.Application.Run(new frmSpriteCreator()); }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-28 02:56:03
|
Revision: 1422 http://sourceforge.net/p/agate/code/1422 Author: kanato Date: 2014-07-28 02:55:51 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Refactor the application models. Make the serial model run on a separate rendering thread. Modified Paths: -------------- trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib/ApplicationModels/ModelParameters.cs trunk/AgateLib/Core.cs trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs trunk/AgateLib/DisplayLib/DisplayWindow.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/Geometry/Size.cs trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs trunk/AgateLib.Platform.WindowsForms/Configuration.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs trunk/Drivers/AgateDrawing/AgateDrawing.csproj trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs trunk/Tests/AudioTests/SoundbufferStopTester.cs trunk/Tests/AudioTests/StreamAudio.cs trunk/Tests/CoreTests/ErrorReport/ErrorReport.cs trunk/Tests/CoreTests/PersistantSettingsTest.cs trunk/Tests/CoreTests/Resources.cs trunk/Tests/CoreTests/Timers/Timers.cs trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs trunk/Tests/DisplayTests/Capabilities/Capabilities.cs trunk/Tests/DisplayTests/ClipRect.cs trunk/Tests/DisplayTests/ColorTest.cs trunk/Tests/DisplayTests/DisplayWindowEvents.cs trunk/Tests/DisplayTests/FullScreen.cs trunk/Tests/DisplayTests/MultipleFramebufferTest.cs trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs trunk/Tests/DisplayTests/PixelBufferMask.cs trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs trunk/Tests/DisplayTests/Prerendered.cs trunk/Tests/DisplayTests/RenderStates/RenderStates.cs trunk/Tests/DisplayTests/RenderTargetContinuous.cs trunk/Tests/DisplayTests/RotatingSpriteTester.cs trunk/Tests/DisplayTests/ScreenCapture.cs trunk/Tests/DisplayTests/SpriteTester/SpriteTester.cs trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs trunk/Tests/DisplayTests/TileTester/TileTester.cs trunk/Tests/DisplayTests/Tiling.cs trunk/Tests/Fonts/BitmapFonts.cs trunk/Tests/Fonts/FontAlignment.cs trunk/Tests/Fonts/FontLineTester.cs trunk/Tests/Fonts/Fonts.cs trunk/Tests/Fonts/Kerning.cs trunk/Tests/InputTests/Input/InputTester.cs trunk/Tests/Shaders/CoordinateSystem.cs trunk/Tests/Shaders/Hlsl.cs trunk/Tests/Shaders/Lighting3DTest.cs trunk/Tests/Shaders/LightingTest/LightingTest.cs trunk/UnitTests/Fakes/FakeDisplayDriver.cs trunk/UnitTests/UnitTests.csproj Added Paths: ----------- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModelParameters.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModelParameters.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs trunk/UnitTests/ApplicationModels/ trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs Modified: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -30,6 +30,12 @@ } } + + static Func<int> ActionToFunc(Action entry) + { + return () => { entry(); return 0; }; + } + #endregion DisplayWindow window; @@ -42,8 +48,83 @@ throw new AgateException("Cannot create a new application model when an existing one is active."); Instance = this; + + ProcessArguments(); } + public int Run(Action entry) + { + return RunImpl(entry); + } + public int Run(Func<int> entry) + { + return RunImpl(entry); + } + public int Run(string[] args, Action entry) + { + Parameters.Arguments = args; + + return RunImpl(entry); + } + public int Run(string[] args, Func<int> entry) + { + Parameters.Arguments = args; + + return RunImpl(entry); + } + + private int RunImpl(Action entry) + { + return RunImpl(ActionToFunc(entry)); + } + protected virtual int RunImpl(Func<int> entry) + { + return RunModel(entry); + } + + protected virtual void ProcessArguments() + { + if (Parameters.Arguments == null) return; + + for(int i = 0; i < Parameters.Arguments.Length; i++) + { + var arg = Parameters.Arguments[i]; + int extraArguments = Parameters.Arguments.Length - i- 1; + bool nextArgIsParam = extraArguments > 0 && Parameters.Arguments[i+1].StartsWith("--") == false; + + if (arg.StartsWith("--")) + { + if (nextArgIsParam) + { + ProcessArgument(arg, Parameters.Arguments[i + 1]); + i++; + } + else + ProcessArgument(arg, ""); + } + } + } + + protected virtual void ProcessArgument(string arg, string parm) + { + switch(arg) + { + case "--window": + Parameters.CreateFullScreenWindow = false; + Parameters.DisplayWindowSize = Size.FromString(parm); + break; + + default: + break; + } + } + + private Size ParseSize(string parm) + { + Size.FromString(parm); + throw new NotImplementedException(); + } + protected int RunModel(Func<int> entryPoint) { try @@ -65,7 +146,7 @@ } protected abstract int BeginModel(Func<int> entryPoint); - + private void AutoCreateDisplayWindow() { if (Parameters.AutoCreateDisplayWindow == false) @@ -77,8 +158,30 @@ Parameters.ApplicationName, GetFullScreenSize()); } + else + { + window = DisplayWindow.CreateWindowed( + Parameters.ApplicationName, + GetWindowedScreenSize()); + } } + private Size GetWindowedScreenSize() + { + if (Parameters.DisplayWindowSize.IsEmpty) + { + var size = Display.Caps.NativeScreenResolution; + size.Width -= 60; + size.Height -= 60; + + return size; + } + else + { + return Parameters.DisplayWindowSize; + } + } + private Size GetFullScreenSize() { if (Parameters.DisplayWindowSize.IsEmpty) @@ -92,12 +195,14 @@ private Size GetScreenSize() { - return Display.Caps.ScreenResolution; + return Display.Caps.NativeScreenResolution; } protected abstract void Initialize(); protected abstract void Dispose(); + protected DisplayWindow AutoCreatedWindow { get { return window; } } + public ModelParameters Parameters { get; set; } } } Modified: trunk/AgateLib/ApplicationModels/ModelParameters.cs =================================================================== --- trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -13,7 +13,9 @@ public ModelParameters() { + AutoCreateDisplayWindow = true; CreateFullScreenWindow = true; + ApplicationName = "AgateLib Application"; } public ModelParameters(string[] args) : this() { @@ -26,19 +28,6 @@ public Size DisplayWindowSize { get; set; } public bool CreateFullScreenWindow { get; set; } - public string[] Arguments - { - get { return args; } - set - { - args = value; - ParseArguments(); - } - } - - private void ParseArguments() - { - } - + public string[] Arguments { get; set; } } } Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/Core.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -328,7 +328,7 @@ FileSystem.File = factory.PlatformFactory.CreateFile(); FileSystem.Path = factory.PlatformFactory.CreatePath(); - + Display.Initialize(factory.DisplayFactory.CreateDisplayImpl()); Audio.Initialize(factory.AudioFactory.CreateAudioImpl()); JoystickInput.Initialize(factory.InputFactory.CreateJoystickInputImpl()); @@ -449,7 +449,7 @@ /// <returns></returns> internal static double GetTime() { - return mTime.TotalSeconds; + return mTime.TotalMilliseconds; } Modified: trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -140,10 +140,21 @@ get { return Display.Impl.CapsSize(DisplaySizeCaps.MaxSurfaceSize); } } - public Size ScreenResolution + /// <summary> + /// Gets the native resolution of the main screen. + /// </summary> + public Size NativeScreenResolution { get { return Display.Impl.CapsSize(DisplaySizeCaps.NativeScreenResolution); } } + + /// <summary> + /// Gets the aspect ratio of the monitor. + /// </summary> + public double AspectRatio + { + get { return Display.Impl.CapsDouble(DisplayDoubleCaps.AspectRatio); } + } } /// <summary> @@ -213,4 +224,11 @@ /// </summary> CanCreateBitmapFont, } + public enum DisplayDoubleCaps + { + /// <summary> + /// Indicates the aspect ratio (width / height) of the main monitor. + /// </summary> + AspectRatio, + } } Modified: trunk/AgateLib/DisplayLib/DisplayWindow.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayWindow.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/DisplayLib/DisplayWindow.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -136,6 +136,17 @@ /// This overload creates a window which has the default icon and is not resizeable. /// </summary> /// <param name="title"></param> + /// <param name="size"></param> + /// <returns></returns> + public static DisplayWindow CreateWindowed(string title, Size size) + { + return DisplayWindow.CreateWindowed(title, size.Width, size.Height); + } + /// <summary> + /// Creates a DisplayWindow object which generates a desktop window to render into. + /// This overload creates a window which has the default icon and is not resizeable. + /// </summary> + /// <param name="title"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -56,8 +56,15 @@ /// </summary> /// <param name="displaySizeCaps"></param> /// <returns></returns> - public abstract Size CapsSize(DisplaySizeCaps displaySizeCaps); + public abstract Size CapsSize(DisplaySizeCaps caps); + /// <summary> + /// Gets a caps value which should return a floating point value. + /// </summary> + /// <param name="caps"></param> + /// <returns></returns> + public abstract double CapsDouble(DisplayDoubleCaps caps); + #endregion public abstract IEnumerable<DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages { get; } Modified: trunk/AgateLib/Geometry/Size.cs =================================================================== --- trunk/AgateLib/Geometry/Size.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib/Geometry/Size.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -187,6 +187,8 @@ string[] values = str.Split(','); Size retval = new Size(); + if (values.Length == 1 && str.Contains("x") && str.Contains("=") == false) + values = str.Split('x'); if (values.Length != 2) throw new FormatException("Could not parse size data from text."); Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-28 02:55:51 UTC (rev 1422) @@ -71,8 +71,10 @@ <ItemGroup> <Compile Include="ApplicationModels\FormsModelBase.cs" /> <Compile Include="ApplicationModels\PassiveModel.cs" /> + <Compile Include="ApplicationModels\PassiveModelParameters.cs" /> <Compile Include="ApplicationModels\SceneModel.cs" /> <Compile Include="ApplicationModels\SerialModel.cs" /> + <Compile Include="ApplicationModels\SerialModelParameters.cs" /> <Compile Include="Diagnostics\AgateConsoleImpl.cs" /> <Compile Include="Diagnostics\AgateConsoleTraceListener.cs" /> <Compile Include="DisplayImplementation\frmFullScreen.cs"> @@ -85,6 +87,7 @@ <Compile Include="DisplayImplementation\GL_DisplayControl.cs" /> <Compile Include="DisplayImplementation\GL_GameWindow.cs" /> <Compile Include="DisplayImplementation\GL_Surface.cs" /> + <Compile Include="DisplayImplementation\IPrimaryWindow.cs" /> <Compile Include="Factories\DisplayFactory.cs" /> <Compile Include="Factories\FormsFactory.cs" /> <Compile Include="Factories\PlatformFactory.cs" /> Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -13,66 +13,31 @@ static PassiveModel() { - DefaultParameters = new ModelParameters - { - ApplicationName = "AgateLib Application", - AutoCreateDisplayWindow = false, - }; + DefaultParameters = new PassiveModelParameters(); } - static Func<int> ActionToFunc(Action entry) - { - return () => { entry(); return 0; }; - } - public static int Run(Action entry) - { - return RunImpl(entry); - } - public static int Run(Func<int> entry) - { - return RunImpl(entry); - } - public static int Run(string[] args, Action entry) - { - DefaultParameters.Arguments = args; + + public static PassiveModelParameters DefaultParameters { get; set; } - return RunImpl(entry); - } - public static int Run(string[] args, Func<int> entry) - { - DefaultParameters.Arguments = args; + #endregion - return RunImpl(entry); - } - public static int Run(ModelParameters parameters, Action entry) + public PassiveModel() : this(DefaultParameters) + { } + + public PassiveModel(PassiveModelParameters parameters) + : base(parameters) { - DefaultParameters = parameters; - - return RunImpl(entry); } - public static int Run(ModelParameters parameters, Func<int> entry) + public PassiveModel(string[] args) : this(DefaultParameters) { - DefaultParameters = parameters; + Parameters.Arguments = args; - return RunImpl(entry); + ProcessArguments(); } - private static int RunImpl(Action entry) - { - return RunImpl(ActionToFunc(entry)); - } - private static int RunImpl(Func<int> entry) - { - return new PassiveModel(DefaultParameters).RunModel(entry); - } - public static ModelParameters DefaultParameters { get; set; } - - #endregion - - PassiveModel(ModelParameters parameters) - : base(parameters) + public new PassiveModelParameters Parameters { - + get { return (PassiveModelParameters)base.Parameters; } } protected override int BeginModel(Func<int> entryPoint) Added: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModelParameters.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModelParameters.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModelParameters.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -0,0 +1,17 @@ +using AgateLib.ApplicationModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Platform.WindowsForms.ApplicationModels +{ + public class PassiveModelParameters : ModelParameters + { + public PassiveModelParameters() + { + AutoCreateDisplayWindow = false; + } + } +} Modified: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -1,35 +1,67 @@ using AgateLib.ApplicationModels; +using AgateLib.Platform.WindowsForms.DisplayImplementation; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace AgateLib.Platform.WindowsForms.ApplicationModels { public class SerialModel : FormsModelBase { + #region --- Static Members --- + static SerialModel() { - DefaultParameters = new ModelParameters - { - ApplicationName = "AgateLib Application", - AutoCreateDisplayWindow = true, - }; + DefaultParameters = new SerialModelParameters(); } - private SerialModel(ModelParameters parameters) : base(parameters) + + public static SerialModelParameters DefaultParameters { get; set; } + + #endregion + + public SerialModel() : this(DefaultParameters) { } - public static void Run(string[] parameters, Action entryPoint) + public SerialModel(SerialModelParameters parameters) + : base(parameters) { - Configuration.Initialize(); } + public SerialModel(string[] args) : this(DefaultParameters) + { + Parameters.Arguments = args; - public static ModelParameters DefaultParameters { get; set; } + ProcessArguments(); + } + public new SerialModelParameters Parameters + { + get { return (SerialModelParameters)base.Parameters; } + } + + int ExecuteEntry(Func<int> entryPoint) + { + OpenTK.Graphics.GraphicsContext.ShareContexts = true; + var window = AutoCreatedWindow.Impl as IPrimaryWindow; + + window.ReinitializeFramebuffer(); + + return entryPoint(); + } protected override int BeginModel(Func<int> entryPoint) { - throw new NotImplementedException(); + int retval = 0; + Thread thread = new Thread(() => { retval = ExecuteEntry(entryPoint); }); + thread.Start(); + + var primaryWindow = AutoCreatedWindow.Impl as IPrimaryWindow; + + primaryWindow.RunApplication(); + + return retval; } + } } Added: trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModelParameters.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModelParameters.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModelParameters.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -0,0 +1,13 @@ +using AgateLib.ApplicationModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Platform.WindowsForms.ApplicationModels +{ + public class SerialModelParameters : ModelParameters + { + } +} Modified: trunk/AgateLib.Platform.WindowsForms/Configuration.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Configuration.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/Configuration.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -21,6 +21,11 @@ public static void Initialize() { Core.Initialize(new FormsFactory()); + + Resources.AddPath("."); + Images.AddPath("."); + Sounds.AddPath("."); + MusicProvider.AddPath("."); } public static FileProviderList Resources { get { return mResourceProvider; } } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -578,9 +578,9 @@ return false; } - public override Size CapsSize(DisplaySizeCaps displaySizeCaps) + public override Size CapsSize(DisplaySizeCaps caps) { - switch (displaySizeCaps) + switch (caps) { case DisplaySizeCaps.NativeScreenResolution: return WinForms.Interop.Convert( @@ -595,6 +595,22 @@ return new Size(0, 0); } + public override double CapsDouble(DisplayDoubleCaps caps) + { + switch(caps) + { + case DisplayDoubleCaps.AspectRatio: + return AspectRatio(CapsSize(DisplaySizeCaps.NativeScreenResolution)); + } + + return 0; + } + + private double AspectRatio(Size size) + { + return size.Width / (double)size.Height; + } + public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages { get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.Glsl; } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -43,7 +43,7 @@ /// <summary> /// No OpenGL code here. /// </summary> - public sealed class GL_DisplayControl : DisplayWindowImpl + public sealed class GL_DisplayControl : DisplayWindowImpl, IPrimaryWindow { DisplayWindow mOwner; Form frm; @@ -84,6 +84,7 @@ "which does not derive from System.Windows.Forms.Control.", windowParams.RenderTarget.GetType().Name)); mRenderTarget = (Control)windowParams.RenderTarget; + mWindowInfo = CreateWindowInfo(CreateGraphicsMode()); if (mRenderTarget.TopLevelControl == null) throw new ArgumentException("The specified render target has not been added to a Form yet. " + @@ -96,7 +97,8 @@ mDisplay = Display.Impl as DesktopGLDisplay; - CreateContext(); + mContext = CreateContext(); + mFrameBuffer = CreateFrameBuffer(); AttachEvents(); } @@ -148,12 +150,11 @@ frm.TopLevel = true; mRenderTarget = frm; + mWindowInfo = CreateWindowInfo(CreateGraphicsMode()); AttachEvents(); + ReinitializeFramebuffer(); - CreateContext(); - - OpenTK.DisplayResolution resolution = OpenTK.DisplayDevice.Default.SelectResolution( mChooseWidth, mChooseHeight, 32, 0); OpenTK.DisplayDevice.Default.ChangeResolution(resolution); @@ -194,12 +195,13 @@ frm = myform; mRenderTarget = myRenderTarget; + mWindowInfo = CreateWindowInfo(CreateGraphicsMode()); if (mIcon != null) frm.Icon = mIcon; - frm.Show(); - CreateContext(); + frm.Show(); + ReinitializeFramebuffer(); AttachEvents(); @@ -210,28 +212,42 @@ Core.IsActive = true; } - private void CreateContext() + public void ReinitializeFramebuffer() { - GraphicsMode newMode = new GraphicsMode( - GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, - 0, 0, new ColorFormat(0), 2, false); + mContext = CreateContext(); + mFrameBuffer = CreateFrameBuffer(); + } + public OpenTK.Graphics.GraphicsContext CreateContext() + { + GraphicsMode newMode = CreateGraphicsMode(); + Debug.Print("AgateLib GraphicsMode: {0}", newMode); - - mWindowInfo = CreateWindowInfo(newMode); - GraphicsContextFlags flags = GraphicsContextFlags.Default; #if DEBUG //flags = GraphicsContextFlags.ForwardCompatible; #endif - mContext = new OpenTK.Graphics.GraphicsContext(newMode, mWindowInfo, 3, 1, flags); - mContext.MakeCurrent(mWindowInfo); - (mContext as IGraphicsContextInternal).LoadAll(); + var context = new OpenTK.Graphics.GraphicsContext(newMode, mWindowInfo, 3, 1, flags); + context.MakeCurrent(mWindowInfo); + (context as IGraphicsContextInternal).LoadAll(); - mFrameBuffer = new ContextFB(mOwner, mContext, mWindowInfo, this.Size, true, false); + return context; } + private static GraphicsMode CreateGraphicsMode() + { + GraphicsMode newMode = new GraphicsMode( + GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, + 0, 0, new ColorFormat(0), 2, false); + return newMode; + } + + private ContextFB CreateFrameBuffer() + { + return new ContextFB(mOwner, mContext, mWindowInfo, this.Size, true, false); + } + private IWindowInfo CreateWindowInfo(GraphicsMode mode) { switch (AgateLib.Core.Platform.PlatformType) @@ -581,7 +597,6 @@ Keyboard.ReleaseAllKeys(); } - #region GL_IRenderTarget Members @@ -595,5 +610,10 @@ } #endregion + + void IPrimaryWindow.RunApplication() + { + Application.Run(frm); + } } } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -35,7 +35,7 @@ /// <summary> /// Old, needs to be updated. /// </summary> - class GL_GameWindow : DisplayWindowImpl + class GL_GameWindow : DisplayWindowImpl, IPrimaryWindow { #region --- Static Members --- @@ -202,8 +202,7 @@ else CreateWindowedDisplay(); - mFrameBuffer = new ContextFB(mOwner, mWindow.Context, mWindow.WindowInfo, - new Size(mWindow.ClientSize.Width, mWindow.ClientSize.Height), true, false); + CreateFrameBuffer(); mDisplay = Display.Impl as DesktopGLDisplay; @@ -212,8 +211,21 @@ mDisplay.InitializeCurrentContext(); mDrawBuffer = mDisplay.CreateDrawBuffer(); + } + private void CreateFrameBuffer() + { + GraphicsContext context = new GraphicsContext(mWindow.Context.GraphicsMode, mWindow.WindowInfo); + Debug.WriteLine(string.Format("Created context {0}", context.ToString())); + mFrameBuffer = new ContextFB(mOwner, context, mWindow.WindowInfo, + new Size(mWindow.ClientSize.Width, mWindow.ClientSize.Height), true, false); + + if (mOwner.Impl != null) + { + // force recreation of the parent FrameBuffer object which wraps mFrameBuffer. + Display.RenderTarget = mOwner.FrameBuffer; + } } public override FrameBufferImpl FrameBuffer @@ -495,5 +507,21 @@ } #endregion + + public void RunApplication() + { + mWindow.Run(); + } + + + void IPrimaryWindow.RunApplication() + { + mWindow.Run(); + } + + public void ReinitializeFramebuffer() + { + CreateFrameBuffer(); + } } } Added: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/IPrimaryWindow.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -0,0 +1,10 @@ +using System; +namespace AgateLib.Platform.WindowsForms.DisplayImplementation +{ + interface IPrimaryWindow + { + void RunApplication(); + + void ReinitializeFramebuffer(); + } +} Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,6 +25,7 @@ public DiagnosticsStopwatch() : this(true) { + watch.Start(); } /// <summary> /// Constructs a timer object. Modified: trunk/Drivers/AgateDrawing/AgateDrawing.csproj =================================================================== --- trunk/Drivers/AgateDrawing/AgateDrawing.csproj 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Drivers/AgateDrawing/AgateDrawing.csproj 2014-07-28 02:55:51 UTC (rev 1422) @@ -152,10 +152,6 @@ <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> <Name>AgateLib</Name> </ProjectReference> - <ProjectReference Include="..\AgateLib.WinForms\AgateLib.WinForms.csproj"> - <Project>{BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}</Project> - <Name>AgateLib.WinForms</Name> - </ProjectReference> </ItemGroup> <ItemGroup> <None Include="packages.config" /> Modified: trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs =================================================================== --- trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -17,7 +17,7 @@ /// </summary> public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { new frmAudioTester().ShowDialog(); }); Modified: trunk/Tests/AudioTests/SoundbufferStopTester.cs =================================================================== --- trunk/Tests/AudioTests/SoundbufferStopTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/AudioTests/SoundbufferStopTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -30,7 +30,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = new DisplayWindow(CreateWindowParams.Windowed( "Sound Buffer Tester", 640, 480, false, null)); Modified: trunk/Tests/AudioTests/StreamAudio.cs =================================================================== --- trunk/Tests/AudioTests/StreamAudio.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/AudioTests/StreamAudio.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -107,7 +107,7 @@ } public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Generate Audio", 640, 480); Modified: trunk/Tests/CoreTests/ErrorReport/ErrorReport.cs =================================================================== --- trunk/Tests/CoreTests/ErrorReport/ErrorReport.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/CoreTests/ErrorReport/ErrorReport.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -14,7 +14,7 @@ [STAThread] public void Main(string[] args) { - PassiveModel.Run(args, () => new frmErrorReportTester().ShowDialog()); + new PassiveModel(args).Run( () => new frmErrorReportTester().ShowDialog()); } Modified: trunk/Tests/CoreTests/PersistantSettingsTest.cs =================================================================== --- trunk/Tests/CoreTests/PersistantSettingsTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/CoreTests/PersistantSettingsTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -23,10 +23,10 @@ public void Main(string[] args) { - PassiveModel.Run(new ModelParameters(args) + new PassiveModel(new PassiveModelParameters() { ApplicationName = "Testing", - }, () => + }).Run(args, () => { if (Core.Settings["Testy"].IsEmpty) { Modified: trunk/Tests/CoreTests/Resources.cs =================================================================== --- trunk/Tests/CoreTests/Resources.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/CoreTests/Resources.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -15,7 +15,7 @@ { public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { Configuration.Resources.AddPath("Data"); Modified: trunk/Tests/CoreTests/Timers/Timers.cs =================================================================== --- trunk/Tests/CoreTests/Timers/Timers.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/CoreTests/Timers/Timers.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -14,7 +14,7 @@ { public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { frmTimerTester frm = new frmTimerTester(); frm.Show(); Modified: trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs =================================================================== --- trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -77,7 +77,7 @@ [STAThread] public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { // create a random number generation object // so that we can make pretty colors. Modified: trunk/Tests/DisplayTests/Capabilities/Capabilities.cs =================================================================== --- trunk/Tests/DisplayTests/Capabilities/Capabilities.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/Capabilities/Capabilities.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -23,7 +23,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { new frmCapabilities().ShowDialog(); }); Modified: trunk/Tests/DisplayTests/ClipRect.cs =================================================================== --- trunk/Tests/DisplayTests/ClipRect.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/ClipRect.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,7 +25,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed( "Test clip rects", 640, 480); Modified: trunk/Tests/DisplayTests/ColorTest.cs =================================================================== --- trunk/Tests/DisplayTests/ColorTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/ColorTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,7 +25,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed( "Color Test", 640, 480); Modified: trunk/Tests/DisplayTests/DisplayWindowEvents.cs =================================================================== --- trunk/Tests/DisplayTests/DisplayWindowEvents.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/DisplayWindowEvents.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -27,7 +27,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Display Window Events", 640, 480, true); Modified: trunk/Tests/DisplayTests/FullScreen.cs =================================================================== --- trunk/Tests/DisplayTests/FullScreen.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/FullScreen.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,7 +25,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateFullScreen("Hello World", 640, 480); Surface mySurface = new Surface("jellybean.png"); Modified: trunk/Tests/DisplayTests/MultipleFramebufferTest.cs =================================================================== --- trunk/Tests/DisplayTests/MultipleFramebufferTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/MultipleFramebufferTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -33,7 +33,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Multiple Framebuffer Test", 640, 480); Modified: trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs =================================================================== --- trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -31,7 +31,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { MultipleRenderTargetExample myForm = new MultipleRenderTargetExample(); myForm.Show(); Modified: trunk/Tests/DisplayTests/PixelBufferMask.cs =================================================================== --- trunk/Tests/DisplayTests/PixelBufferMask.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/PixelBufferMask.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -24,7 +24,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow window = DisplayWindow.CreateWindowed("Test", 800, 600); Modified: trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs =================================================================== --- trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,7 +25,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { frm = new PixelBufferForm(); frm.Show(); Modified: trunk/Tests/DisplayTests/Prerendered.cs =================================================================== --- trunk/Tests/DisplayTests/Prerendered.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/Prerendered.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -22,7 +22,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow MainWindow = DisplayWindow.CreateWindowed("Test", 800, 600); FrameBuffer myBuffer = new FrameBuffer(200, 35); Modified: trunk/Tests/DisplayTests/RenderStates/RenderStates.cs =================================================================== --- trunk/Tests/DisplayTests/RenderStates/RenderStates.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/RenderStates/RenderStates.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -24,7 +24,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { frmRenderStateTest frm = new frmRenderStateTest(); frm.Show(); Modified: trunk/Tests/DisplayTests/RenderTargetContinuous.cs =================================================================== --- trunk/Tests/DisplayTests/RenderTargetContinuous.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/RenderTargetContinuous.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -24,7 +24,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed(Name, 300, 300); FrameBuffer buffer = new FrameBuffer(300, 300); Modified: trunk/Tests/DisplayTests/RotatingSpriteTester.cs =================================================================== --- trunk/Tests/DisplayTests/RotatingSpriteTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/RotatingSpriteTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,7 +25,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Rotating sprite", 300, 300); Sprite sp = new Sprite("spike.png", 16, 16); Modified: trunk/Tests/DisplayTests/ScreenCapture.cs =================================================================== --- trunk/Tests/DisplayTests/ScreenCapture.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/ScreenCapture.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -22,7 +22,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Hello", 800, 600); Surface someSurface = new Surface("wallpaper.png"); Modified: trunk/Tests/DisplayTests/SpriteTester/SpriteTester.cs =================================================================== --- trunk/Tests/DisplayTests/SpriteTester/SpriteTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/SpriteTester/SpriteTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -20,7 +20,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { frmSpriteTester form = new frmSpriteTester(); Modified: trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs =================================================================== --- trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -22,7 +22,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { frmSurfaceTester form = new frmSurfaceTester(); Modified: trunk/Tests/DisplayTests/TileTester/TileTester.cs =================================================================== --- trunk/Tests/DisplayTests/TileTester/TileTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/TileTester/TileTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -23,7 +23,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { frmTileTester frm = new frmTileTester(); frm.Show(); Modified: trunk/Tests/DisplayTests/Tiling.cs =================================================================== --- trunk/Tests/DisplayTests/Tiling.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/DisplayTests/Tiling.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -20,12 +20,12 @@ [STAThread] static void Main(string[] args) { - PassiveModel.Run(new ModelParameters(args) + new PassiveModel(new PassiveModelParameters() { AutoCreateDisplayWindow = true, DisplayWindowSize = new Size(600, 600), CreateFullScreenWindow = false, - }, + }).Run(args, () => { DisplayWindow wnd = DisplayWindow.CreateWindowed("Tiling Test", 600, 600); Modified: trunk/Tests/Fonts/BitmapFonts.cs =================================================================== --- trunk/Tests/Fonts/BitmapFonts.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Fonts/BitmapFonts.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -22,11 +22,11 @@ public void Main(string[] args) { - PassiveModel.Run(new ModelParameters(args) + new PassiveModel(new PassiveModelParameters() { ApplicationName = "Bitmap Font Tester", DisplayWindowSize = new Size(800, 600), - }, () => + }).Run(args, () => { Display.BeginFrame(); Display.Clear(Color.Navy); Modified: trunk/Tests/Fonts/FontAlignment.cs =================================================================== --- trunk/Tests/Fonts/FontAlignment.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Fonts/FontAlignment.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -27,7 +27,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed( "Bitmap Font Tester", 800, 600, false); Modified: trunk/Tests/Fonts/FontLineTester.cs =================================================================== --- trunk/Tests/Fonts/FontLineTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Fonts/FontLineTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -27,7 +27,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Font Line Tester", 640, 480); Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); Modified: trunk/Tests/Fonts/Fonts.cs =================================================================== --- trunk/Tests/Fonts/Fonts.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Fonts/Fonts.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -23,7 +23,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Font Tester", 800, 600); DisplayWindow fullWind = null; Modified: trunk/Tests/Fonts/Kerning.cs =================================================================== --- trunk/Tests/Fonts/Kerning.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Fonts/Kerning.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -28,7 +28,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); DisplayWindow wind = DisplayWindow.CreateWindowed("Kerning test", 800, 600); Modified: trunk/Tests/InputTests/Input/InputTester.cs =================================================================== --- trunk/Tests/InputTests/Input/InputTester.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/InputTests/Input/InputTester.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -20,7 +20,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { new frmInputTester().ShowDialog(); }); Modified: trunk/Tests/Shaders/CoordinateSystem.cs =================================================================== --- trunk/Tests/Shaders/CoordinateSystem.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Shaders/CoordinateSystem.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -25,7 +25,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); Modified: trunk/Tests/Shaders/Hlsl.cs =================================================================== --- trunk/Tests/Shaders/Hlsl.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Shaders/Hlsl.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -59,7 +59,7 @@ } private void Run(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { wind = DisplayWindow.CreateWindowed("HLSL", 800, 600); Mouse.MouseDown += new InputEventHandler(Mouse_MouseDown); Modified: trunk/Tests/Shaders/Lighting3DTest.cs =================================================================== --- trunk/Tests/Shaders/Lighting3DTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Shaders/Lighting3DTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -38,7 +38,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { DisplayWindow wind = DisplayWindow.CreateWindowed("Lighting 3D", 640, 480); FontSurface font = BuiltinResources.AgateSerif14; Modified: trunk/Tests/Shaders/LightingTest/LightingTest.cs =================================================================== --- trunk/Tests/Shaders/LightingTest/LightingTest.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/Tests/Shaders/LightingTest/LightingTest.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -22,7 +22,7 @@ public void Main(string[] args) { - PassiveModel.Run(args, () => + new PassiveModel(args).Run( () => { //LightingTestForm frm = new LightingTestForm(); //frm.Show(); Added: trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs =================================================================== --- trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs (rev 0) +++ trunk/UnitTests/ApplicationModels/ArgumentProcessing.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -0,0 +1,48 @@ +using AgateLib.ApplicationModels; +using AgateLib.Geometry; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.UnitTests.ApplicationModels +{ + public class ArgumentProcessing : AgateAppModel + { + public ArgumentProcessing(ModelParameters param) : base(param) + { + + } + protected override int BeginModel(Func<int> entryPoint) + { + return 0; + } + + protected override void Initialize() + { + } + + protected override void Dispose() + { + } + } + + [TestClass] + public class ArgumentProcessorTest + { + [TestMethod] + public void SetWindowSizeTest() + { + ArgumentProcessing p = new ArgumentProcessing(new ModelParameters + { + Arguments = + "--window 640x480".Split(' ') + }); + + Assert.IsFalse(p.Parameters.CreateFullScreenWindow); + Assert.AreEqual(new Size(640, 480), p.Parameters.DisplayWindowSize); + } + } +} Modified: trunk/UnitTests/Fakes/FakeDisplayDriver.cs =================================================================== --- trunk/UnitTests/Fakes/FakeDisplayDriver.cs 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/UnitTests/Fakes/FakeDisplayDriver.cs 2014-07-28 02:55:51 UTC (rev 1422) @@ -13,6 +13,10 @@ { throw new NotImplementedException(); } + public override double CapsDouble(DisplayLib.DisplayDoubleCaps caps) + { + throw new NotImplementedException(); + } public override AgateLib.Geometry.Size CapsSize(AgateLib.DisplayLib.DisplaySizeCaps displaySizeCaps) { Modified: trunk/UnitTests/UnitTests.csproj =================================================================== --- trunk/UnitTests/UnitTests.csproj 2014-07-26 17:13:50 UTC (rev 1421) +++ trunk/UnitTests/UnitTests.csproj 2014-07-28 02:55:51 UTC (rev 1422) @@ -87,6 +87,7 @@ </Otherwise> </Choose> <ItemGroup> + <Compile Include="ApplicationModels\ArgumentProcessing.cs" /> <Compile Include="Core\ConsoleTests.cs" /> <Compile Include="Display\DisplayTests.cs" /> <Compile Include="Extensions\ListExtensions.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-26 17:13:57
|
Revision: 1421 http://sourceforge.net/p/agate/code/1421 Author: kanato Date: 2014-07-26 17:13:50 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Update version numbers to 2.0. Modified Paths: -------------- trunk/AgateLib/Properties/AssemblyInfo.cs trunk/AgateLib.GL/Properties/AssemblyInfo.cs trunk/AgateLib.Platform.WindowsForms/Properties/AssemblyInfo.cs trunk/IntegrationTests/Properties/AssemblyInfo.cs trunk/Tests/Properties/AssemblyInfo.cs trunk/Tools/FontCreator/Properties/AssemblyInfo.cs trunk/Tools/PackedSpriteCreator/Properties/AssemblyInfo.cs trunk/Tools/ResourceEditor/Properties/AssemblyInfo.cs trunk/UnitTests/Properties/AssemblyInfo.cs Modified: trunk/AgateLib/Properties/AssemblyInfo.cs =================================================================== --- trunk/AgateLib/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/AgateLib/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -44,6 +44,6 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] [assembly: NeutralResourcesLanguageAttribute("en")] Modified: trunk/AgateLib.GL/Properties/AssemblyInfo.cs =================================================================== --- trunk/AgateLib.GL/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/AgateLib.GL/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -33,5 +33,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/AgateLib.Platform.WindowsForms/Properties/AssemblyInfo.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/AgateLib.Platform.WindowsForms/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/IntegrationTests/Properties/AssemblyInfo.cs =================================================================== --- trunk/IntegrationTests/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/IntegrationTests/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/Tests/Properties/AssemblyInfo.cs =================================================================== --- trunk/Tests/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/Tests/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/Tools/FontCreator/Properties/AssemblyInfo.cs =================================================================== --- trunk/Tools/FontCreator/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/Tools/FontCreator/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/Tools/PackedSpriteCreator/Properties/AssemblyInfo.cs =================================================================== --- trunk/Tools/PackedSpriteCreator/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/Tools/PackedSpriteCreator/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/Tools/ResourceEditor/Properties/AssemblyInfo.cs =================================================================== --- trunk/Tools/ResourceEditor/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/Tools/ResourceEditor/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/UnitTests/Properties/AssemblyInfo.cs =================================================================== --- trunk/UnitTests/Properties/AssemblyInfo.cs 2014-07-26 15:38:21 UTC (rev 1420) +++ trunk/UnitTests/Properties/AssemblyInfo.cs 2014-07-26 17:13:50 UTC (rev 1421) @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-26 15:38:24
|
Revision: 1420 http://sourceforge.net/p/agate/code/1420 Author: kanato Date: 2014-07-26 15:38:21 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Fix XleSerializer unit test. Modified Paths: -------------- trunk/AgateLib/Serialization/Xle/XleSerializer.cs Modified: trunk/AgateLib/Serialization/Xle/XleSerializer.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-07-26 15:33:32 UTC (rev 1419) +++ trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-07-26 15:38:21 UTC (rev 1420) @@ -63,8 +63,11 @@ typeBinder.AddAssembly(objectType.Assembly); typeBinder.AddAssembly(Assembly.GetExecutingAssembly()); - typeBinder.AddAssemblies( - Core.Factory.PlatformFactory.GetSerializationSearchAssemblies(objectType)); + if (Core.Factory != null) + { + typeBinder.AddAssemblies( + Core.Factory.PlatformFactory.GetSerializationSearchAssemblies(objectType)); + } Binder = typeBinder; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-26 15:33:36
|
Revision: 1419 http://sourceforge.net/p/agate/code/1419 Author: kanato Date: 2014-07-26 15:33:32 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Make "Everything" project compile. Modified Paths: -------------- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs trunk/AgateLib-Everything.sln trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs trunk/ChangeLog.txt trunk/Examples/BallBuster.Net/BallBuster.Net.csproj trunk/Examples/BallBuster.Net/CImage.cs trunk/Examples/BallBuster.Net/Program.cs trunk/Examples/BallBuster.Net/ball.cs trunk/Examples/BallBuster.Net/block.cs trunk/Examples/BallBuster.Net/blockpart.cs trunk/Examples/BallBuster.Net/flash.cs trunk/Examples/BallBuster.Net/main.cs trunk/Examples/BallBuster.Net/powerup.cs trunk/Examples/Pong/Pong.cs trunk/Examples/Pong/Pong.csproj trunk/Examples/ShootTheTraps/App.cs trunk/Examples/ShootTheTraps/Particle.cs trunk/Examples/ShootTheTraps/ShootTheTraps.csproj trunk/Tools/FontCreator/CreateFont.Designer.cs trunk/Tools/FontCreator/EditGlyphs.cs trunk/Tools/FontCreator/FontCreator.cs trunk/Tools/FontCreator/FontCreator.csproj trunk/Tools/FontCreator/FontCreatorProgram.cs trunk/Tools/FontCreator/frmFontCreator.cs trunk/Tools/FontCreator/frmWarningSplash.cs trunk/Tools/PackedSpriteCreator/PackedSpriteCreator.csproj trunk/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs trunk/Tools/PackedSpriteCreator/SpriteEditor.cs trunk/Tools/PackedSpriteCreator/SpritePacker.cs trunk/Tools/PackedSpriteCreator/frmSpriteCreator.cs trunk/Tools/ResourceEditor/ResourceEditor.csproj Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -760,15 +760,15 @@ { var attribute = CurrentNode.Attribute(name); - if (attribute == null) - return false; + if (attribute != null) + return true; XElement element = CurrentNode.Element(name); - if (element == null) - return false; + if (element != null) + return true; - return true; + return false; } #region --- Reading single values --- Modified: trunk/AgateLib-Everything.sln =================================================================== --- trunk/AgateLib-Everything.sln 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/AgateLib-Everything.sln 2014-07-26 15:33:32 UTC (rev 1419) @@ -10,12 +10,7 @@ EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{DC687DB2-90A8-484D-AB99-B3D29FDD8D44}" - ProjectSection(ProjectDependencies) = postProject - {00C7FA95-98F4-43D9-9B63-34122B1DB003} = {00C7FA95-98F4-43D9-9B63-34122B1DB003} - EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDL", "Drivers\AgateSDL\AgateSDL.csproj", "{00C7FA95-98F4-43D9-9B63-34122B1DB003}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib", "AgateLib\AgateLib.csproj", "{9490B719-829E-43A7-A5FE-8001F8A81759}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{F22ADCCC-7991-4F52-B2D0-697D60121BB3}" @@ -28,8 +23,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotebookLib", "Tools\NotebookLib\NotebookLib\NotebookLib.csproj", "{91F57346-B574-4D52-9EB0-AA191B552C94}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseEditor", "Tools\DatabaseEditor\DatabaseEditor.csproj", "{685E7B82-4609-4ABB-B25B-0DC7C58BD45F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BallBuster.Net", "Examples\BallBuster.Net\BallBuster.Net.csproj", "{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShootTheTraps", "Examples\ShootTheTraps\ShootTheTraps.csproj", "{50743D1B-A19E-42F1-842F-65FAD6D168C3}" @@ -40,6 +33,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.GL", "AgateLib.GL\AgateLib.GL.csproj", "{94734E5A-0344-43E8-BB30-E32E3F57F611}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.Platform.WindowsForms", "AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj", "{4B12561E-D37B-48A1-B6DB-218E94906C22}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -84,38 +79,12 @@ {DC687DB2-90A8-484D-AB99-B3D29FDD8D44}.Release|x64.Build.0 = Release|x64 {DC687DB2-90A8-484D-AB99-B3D29FDD8D44}.Release|x86.ActiveCfg = Release|x86 {DC687DB2-90A8-484D-AB99-B3D29FDD8D44}.Release|x86.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Win32.ActiveCfg = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x64.ActiveCfg = Debug|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x64.Build.0 = Debug|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x86.ActiveCfg = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x86.Build.0 = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|Any CPU.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|Mixed Platforms.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|Mixed Platforms.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|Win32.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|x64.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|x86.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|x86.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.Build.0 = Release|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Mixed Platforms.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Win32.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x64.ActiveCfg = Release|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x64.Build.0 = Release|x64 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x86.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x86.Build.0 = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.Build.0 = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Mixed Platforms.Build.0 = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Win32.ActiveCfg = Debug|x86 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x64.ActiveCfg = Debug|x64 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x64.Build.0 = Debug|x64 + {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x64.ActiveCfg = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x86.ActiveCfg = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x86.Build.0 = Debug|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Public|Any CPU.ActiveCfg = Release|x86 @@ -130,8 +99,7 @@ {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Mixed Platforms.ActiveCfg = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Mixed Platforms.Build.0 = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Win32.ActiveCfg = Release|x86 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x64.ActiveCfg = Release|x64 - {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x64.Build.0 = Release|x64 + {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x64.ActiveCfg = Release|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x86.ActiveCfg = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x86.Build.0 = Release|x86 {F22ADCCC-7991-4F52-B2D0-697D60121BB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -275,36 +243,6 @@ {91F57346-B574-4D52-9EB0-AA191B552C94}.Release|x64.Build.0 = Release|x64 {91F57346-B574-4D52-9EB0-AA191B552C94}.Release|x86.ActiveCfg = Release|x86 {91F57346-B574-4D52-9EB0-AA191B552C94}.Release|x86.Build.0 = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Win32.ActiveCfg = Debug|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Win32.Build.0 = Debug|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x64.ActiveCfg = Debug|x64 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x64.Build.0 = Debug|x64 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x86.ActiveCfg = Debug|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x86.Build.0 = Debug|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|Any CPU.ActiveCfg = Release|Any CPU - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|Any CPU.Build.0 = Release|Any CPU - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|Mixed Platforms.ActiveCfg = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|Mixed Platforms.Build.0 = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|Win32.ActiveCfg = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|Win32.Build.0 = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|x64.ActiveCfg = Release|x64 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|x64.Build.0 = Release|x64 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|x86.ActiveCfg = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Public|x86.Build.0 = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Any CPU.Build.0 = Release|Any CPU - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Mixed Platforms.Build.0 = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Win32.ActiveCfg = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Win32.Build.0 = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x64.ActiveCfg = Release|x64 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x64.Build.0 = Release|x64 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x86.ActiveCfg = Release|x86 - {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x86.Build.0 = Release|x86 {DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 @@ -443,6 +381,33 @@ {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|x64.ActiveCfg = Release|Any CPU {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|x86.ActiveCfg = Release|x86 {94734E5A-0344-43E8-BB30-E32E3F57F611}.Release|x86.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Win32.ActiveCfg = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|Win32.Build.0 = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|x64.ActiveCfg = Debug|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|x86.ActiveCfg = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Debug|x86.Build.0 = Debug|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|Any CPU.ActiveCfg = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|Any CPU.Build.0 = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|Mixed Platforms.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|Mixed Platforms.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|Win32.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|Win32.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|x64.ActiveCfg = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|x86.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Public|x86.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Any CPU.Build.0 = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Mixed Platforms.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Win32.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|Win32.Build.0 = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x64.ActiveCfg = Release|Any CPU + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x86.ActiveCfg = Release|x86 + {4B12561E-D37B-48A1-B6DB-218E94906C22}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/AgateLib.Platform.WindowsForms/WinForms/FormUtil.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -113,7 +113,7 @@ { AgateLib.Core.ErrorReporting.Report(ErrorLevel.Warning, "Caught a MissingManifestResourceException when looking for the AgateLib Icon. " + - "This indicates a problem with the way resources were embedded into AgateLib.WinForms.dll when it was built.", + "This indicates a problem with the way resources were embedded into AgateLib.Platform.WindowsForms.WinForms.dll when it was built.", e); return null; Modified: trunk/ChangeLog.txt =================================================================== --- trunk/ChangeLog.txt 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/ChangeLog.txt 2014-07-26 15:33:32 UTC (rev 1419) @@ -78,7 +78,7 @@ Linux and MacOS with MonoDevelop. This should help users of other operating systems use and contribute to AgateLib. -Added AgateLib.WinForms.dll to encapsulate all references to System.Drawing and System.Windows.Forms +Added AgateLib.Platform.WindowsForms.WinForms.dll to encapsulate all references to System.Drawing and System.Windows.Forms inside AgateLib.dll. This is the last release of AgateLib.dll which will contain any methods which take System.Drawing types, such as Point and Size. Modified: trunk/Examples/BallBuster.Net/BallBuster.Net.csproj =================================================================== --- trunk/Examples/BallBuster.Net/BallBuster.Net.csproj 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/BallBuster.Net.csproj 2014-07-26 15:33:32 UTC (rev 1419) @@ -157,26 +157,14 @@ </BootstrapperPackage> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> <Name>AgateLib</Name> </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateDrawing\AgateDrawing.csproj"> - <Project>{164a785d-924e-40fb-a517-d7e677f3b53a}</Project> - <Name>AgateDrawing</Name> - </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateOTK\AgateOTK.csproj"> - <Project>{9E095F03-BA3F-4EAD-A905-2A2647CE4405}</Project> - <Name>AgateOTK</Name> - </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateSDL\AgateSDL.csproj"> - <Project>{00C7FA95-98F4-43D9-9B63-34122B1DB003}</Project> - <Name>AgateSDL</Name> - </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateSDX\AgateSDX.csproj"> - <Project>{ef993b30-d9a9-4962-80bb-6826d39b3465}</Project> - <Name>AgateSDX</Name> - </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Modified: trunk/Examples/BallBuster.Net/CImage.cs =================================================================== --- trunk/Examples/BallBuster.Net/CImage.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/CImage.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -25,6 +25,7 @@ using AgateLib.Resources; using AgateLib.Sprites; using AgateLib.DisplayLib; +using AgateLib.Platform.WindowsForms.Resources; namespace BallBuster.Net { @@ -60,8 +61,8 @@ public void preload() { - this.font = FontSurface.AgateSans10; - this.largeFont = FontSurface.AgateSans24; + this.font = BuiltinResources.AgateSans10; + this.largeFont = BuiltinResources.AgateSans24; this.largeFont.SetScale(0.8, 0.8); this.palogo = new Sprite(spritesSrc, "palogo"); Modified: trunk/Examples/BallBuster.Net/Program.cs =================================================================== --- trunk/Examples/BallBuster.Net/Program.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/Program.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -1,39 +1,42 @@ -/***************************************************************************** - Ball: Buster - Copyright (C) 2004-9 Patrick Avella, Erik Ylvisaker +//Ball: Buster +//Copyright (C) 2004-14 Patrick Avella, Erik Ylvisaker - This file is part of Ball: Buster. +//This file is part of Ball: Buster. - Ball: Buster is free software; you can redistribute it and/or modify - it under the terms of the GNU General internal License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +//Ball: Buster is free software; you can redistribute it and/or modify +//it under the terms of the GNU General internal License as published by +//the Free Software Foundation; either version 2 of the License, or +//(at your option) any later version. - Ball: Buster is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General internal License for more details. +//Ball: Buster is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General internal License for more details. - You should have received a copy of the GNU General internal License - along with Ball: Buster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +//You should have received a copy of the GNU General internal License +//along with Ball: Buster; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + using System; using System.Collections.Generic; +using AgateLib.Platform.WindowsForms.ApplicationModels; namespace BallBuster.Net { - static class Program - { - /// <summary> - /// The main entry point for the application. - /// </summary> - [STAThread] - static void Main(string[] args) - { - BBX bbx = new BBX(); + static class Program + { + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + static void Main(string[] args) + { + PassiveModel.Run(args, () => + { + BBX bbx = new BBX(); - bbx.Main(args); - } - } + bbx.Main(args); + }); + } + } } \ No newline at end of file Modified: trunk/Examples/BallBuster.Net/ball.cs =================================================================== --- trunk/Examples/BallBuster.Net/ball.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/ball.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -23,6 +23,7 @@ using AgateLib; using AgateLib.Geometry; +using AgateLib.Platform; namespace BallBuster.Net { Modified: trunk/Examples/BallBuster.Net/block.cs =================================================================== --- trunk/Examples/BallBuster.Net/block.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/block.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -22,6 +22,7 @@ using AgateLib; using AgateLib.DisplayLib; using AgateLib.Geometry; +using AgateLib.Platform; using AgateLib.Sprites; namespace BallBuster.Net Modified: trunk/Examples/BallBuster.Net/blockpart.cs =================================================================== --- trunk/Examples/BallBuster.Net/blockpart.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/blockpart.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -27,6 +27,7 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; using AgateLib.Sprites; +using AgateLib.Platform; namespace BallBuster.Net { Modified: trunk/Examples/BallBuster.Net/flash.cs =================================================================== --- trunk/Examples/BallBuster.Net/flash.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/flash.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -21,6 +21,7 @@ using AgateLib; using AgateLib.DisplayLib; +using AgateLib.Platform; namespace BallBuster.Net { Modified: trunk/Examples/BallBuster.Net/main.cs =================================================================== --- trunk/Examples/BallBuster.Net/main.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/main.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -30,6 +30,8 @@ using AgateLib.Sprites; using AgateLib.InputLib; using AgateLib.AudioLib; +using AgateLib.Platform; +using AgateLib.Platform.WindowsForms; namespace BallBuster.Net { @@ -129,7 +131,7 @@ EditorState editorState = new EditorState(); - Timing.StopWatch mPauseTimer = new Timing.StopWatch(); + IStopwatch mPauseTimer = Timing.CreateStopWatch(); // the variables here are REALLY sloppy, sorry......... :P private string gamemode; @@ -278,68 +280,59 @@ [STAThread] public int Main(string[] args) { - using (AgateSetup setup = new AgateSetup(args)) + if (Display.Caps.IsHardwareAccelerated == false || + AgateBuiltInShaders.Lighting2D == null) { - setup.AskUser = true; - setup.Initialize(true, true, true); + doLighting = false; + } - if (setup.WasCanceled) - return 0; + bool fulls = true; - if (Display.Caps.IsHardwareAccelerated == false || - AgateBuiltInShaders.Lighting2D == null) - { - doLighting = false; - } + if (args.Length > 0) + if (args[0] == "-debug") debugger = true; - bool fulls = true; - - if (args.Length > 0) - if (args[0] == "-debug") debugger = true; - - if (debugger) - { - fulls = false; - playmusic = false; - } + if (debugger) + { fulls = false; + playmusic = false; + } + fulls = false; - // now it gets fun, set up the display mode - DisplayWindow mywindow; + // now it gets fun, set up the display mode + DisplayWindow mywindow; - if (fulls) - mywindow = DisplayWindow.CreateFullScreen("Ball: Buster Xtreme.NET", 800, 600); - else - mywindow = DisplayWindow.CreateWindowed("Ball: Buster Xtreme.NET", 800, 600); + if (fulls) + mywindow = DisplayWindow.CreateFullScreen("Ball: Buster Xtreme.NET", 800, 600); + else + mywindow = DisplayWindow.CreateWindowed("Ball: Buster Xtreme.NET", 800, 600); - Mouse.Hide(); + Mouse.Hide(); - // load the images, initiation frame rate counter, and register signals - AgateLib.AgateFileProvider.Images.AddPath("imgs"); + // load the images, initiation frame rate counter, and register signals + Configuration.Images.AddPath("imgs"); - splash(); + splash(); - img.load(); - snd.load(); + img.load(); + snd.load(); - Mouse.MouseMove += new InputEventHandler(Mouse_MouseMoveEvent); - Mouse.MouseUp += new InputEventHandler(Mouse_MouseUpEvent); - Mouse.MouseDown += new InputEventHandler(Mouse_MouseDownEvent); - Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); + Mouse.MouseMove += new InputEventHandler(Mouse_MouseMoveEvent); + Mouse.MouseUp += new InputEventHandler(Mouse_MouseUpEvent); + Mouse.MouseDown += new InputEventHandler(Mouse_MouseDownEvent); + Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); - loadHighscores(); - loadWorlds(); + loadHighscores(); + loadWorlds(); - //here we go! - run(); + //here we go! + run(); - img.unload(); + img.unload(); - saveHighscores(); + saveHighscores(); - freeWorlds(); - } + freeWorlds(); return 0; } Modified: trunk/Examples/BallBuster.Net/powerup.cs =================================================================== --- trunk/Examples/BallBuster.Net/powerup.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/BallBuster.Net/powerup.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -24,6 +24,7 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; using AgateLib.Sprites; +using AgateLib.Platform; namespace BallBuster.Net { Modified: trunk/Examples/Pong/Pong.cs =================================================================== --- trunk/Examples/Pong/Pong.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/Pong/Pong.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -4,214 +4,211 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; using AgateLib.InputLib; +using AgateLib.Platform.WindowsForms.ApplicationModels; +using AgateLib.Platform.WindowsForms.Resources; namespace Pong { - class Program - { - - /// <summary> - /// The main entry point for the application. - /// </summary> - [STAThread] - static void Main(string[] args) - { - new Program().Run(args); - } + class Program + { - FontSurface font; - int[] score = new int[2]; - string[] names = new string[] { "Player", "CPU" }; + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + static void Main(string[] args) + { + PassiveModel.Run(args, () => + { + new Program().Run(args); + }); + } - Vector2 ball, ballvelocity; - Vector2[] paddle = new Vector2[2]; - - const int paddleHeight = 80; - const int paddleWidth = 16; - const int borderSize = paddleWidth; - const int ballSize = paddleWidth; - const int displayWidth = 800; - const int playAreaWidth = 700; - const int displayHeight = 600; - const float paddleSpeed = 150.0f; + FontSurface font; + int[] score = new int[2]; + string[] names = new string[] { "Player", "CPU" }; - Color paddleColor = Color.LightGray; - Color ballColor = Color.LightGray; + Vector2 ball, ballvelocity; + Vector2[] paddle = new Vector2[2]; - void Run(string[] args) - { - using (AgateSetup setup = new AgateSetup(args)) - { - setup.Initialize(true, false, false); - if (setup.WasCanceled) - return; + const int paddleHeight = 80; + const int paddleWidth = 16; + const int borderSize = paddleWidth; + const int ballSize = paddleWidth; + const int displayWidth = 800; + const int playAreaWidth = 700; + const int displayHeight = 600; + const float paddleSpeed = 150.0f; - DisplayWindow wind = DisplayWindow.CreateWindowed - ("Pong Example", displayWidth, displayHeight); + Color paddleColor = Color.LightGray; + Color ballColor = Color.LightGray; - font = FontSurface.AgateSans14; + void Run(string[] args) + { + DisplayWindow wind = DisplayWindow.CreateWindowed + ("Pong Example", displayWidth, displayHeight); - paddle[0] = new Vector2(50, displayHeight / 2); - paddle[1] = new Vector2(playAreaWidth - 50 - paddleWidth, displayHeight / 2); - ball = new Vector2(playAreaWidth / 2, displayHeight / 2); - ballvelocity = new Vector2(-70, 70); + font = BuiltinResources.AgateSans14; - while (wind.IsClosed == false) - { - Display.BeginFrame(); - Display.Clear(Color.DarkGray); + paddle[0] = new Vector2(50, displayHeight / 2); + paddle[1] = new Vector2(playAreaWidth - 50 - paddleWidth, displayHeight / 2); + ball = new Vector2(playAreaWidth / 2, displayHeight / 2); + ballvelocity = new Vector2(-70, 70); - DrawBorder(); - DrawPaddles(); - DrawBall(); - DrawScore(); + while (wind.IsClosed == false) + { + Display.BeginFrame(); + Display.Clear(Color.DarkGray); - Display.EndFrame(); - Core.KeepAlive(); + DrawBorder(); + DrawPaddles(); + DrawBall(); + DrawScore(); - if (Keyboard.Keys[KeyCode.Escape]) - wind.Dispose(); + Display.EndFrame(); + Core.KeepAlive(); - float time_s = (float)Display.DeltaTime / 1000.0f; + if (Keyboard.Keys[KeyCode.Escape]) + wind.Dispose(); - UpdatePaddles(time_s); - UpdateBall(time_s); + float time_s = (float)Display.DeltaTime / 1000.0f; - } - } - } + UpdatePaddles(time_s); + UpdateBall(time_s); + } + } - private void DrawScore() - { - int x = playAreaWidth + borderSize ; - int y = borderSize * 2; + private void DrawScore() + { + int x = playAreaWidth + borderSize; + int y = borderSize * 2; - font.DrawText(x, y, "Score"); + font.DrawText(x, y, "Score"); - for (int i = 0; i < 2; i++) - { - y += font.FontHeight * 2; - font.DrawText(x, y, names[i]); + for (int i = 0; i < 2; i++) + { + y += font.FontHeight * 2; + font.DrawText(x, y, names[i]); - y += font.FontHeight; - font.DrawText(x, y, score[i].ToString()); - } - } + y += font.FontHeight; + font.DrawText(x, y, score[i].ToString()); + } + } - private void UpdateBall(float time_s) - { - bool newBall = false; + private void UpdateBall(float time_s) + { + bool newBall = false; - ball += ballvelocity * time_s; + ball += ballvelocity * time_s; - // collision with bottom wall - if (ball.Y + ballSize > displayHeight - borderSize && ballvelocity.Y > 0) - ballvelocity.Y *= -1; - - // collision with top wall - if (ball.Y < borderSize && ballvelocity.Y < 0) - ballvelocity.Y *= -1; + // collision with bottom wall + if (ball.Y + ballSize > displayHeight - borderSize && ballvelocity.Y > 0) + ballvelocity.Y *= -1; - if (ball.X < borderSize) - { - newBall = true; - score[1]++; - } - else if (ball.X + ballSize > playAreaWidth) - { - newBall = true; - score[0]++; - } + // collision with top wall + if (ball.Y < borderSize && ballvelocity.Y < 0) + ballvelocity.Y *= -1; - if (newBall) - { - ball = new Vector2(playAreaWidth / 2, displayHeight / 2); - ballvelocity = new Vector2(-90, 90); - } - - // check for paddles - bool increaseSpeed = false; + if (ball.X < borderSize) + { + newBall = true; + score[1]++; + } + else if (ball.X + ballSize > playAreaWidth) + { + newBall = true; + score[0]++; + } - if (ball.X < paddle[0].X + paddleWidth && ballvelocity.X < 0) - { - if (ball.Y + ballSize - 1 >= paddle[0].Y && - ball.Y <= paddle[0].Y + paddleHeight) - { - ballvelocity.X *= -1; - increaseSpeed = true; - } - } - if (ball.X + ballSize >= paddle[1].X && ballvelocity.X > 0) - { - if (ball.Y + ballSize - 1 >= paddle[1].Y && - ball.Y <= paddle[1].Y + paddleHeight) - { - ballvelocity.X *= -1; - increaseSpeed = true; - } - } + if (newBall) + { + ball = new Vector2(playAreaWidth / 2, displayHeight / 2); + ballvelocity = new Vector2(-90, 90); + } - if (increaseSpeed) - { - ballvelocity.X += Math.Sign(ballvelocity.X) * 10.0f; - ballvelocity.Y += Math.Sign(ballvelocity.Y) * 10.0f; - } - } + // check for paddles + bool increaseSpeed = false; - private void UpdatePaddles(float time_s) - { - float paddleMove = paddleSpeed * time_s; + if (ball.X < paddle[0].X + paddleWidth && ballvelocity.X < 0) + { + if (ball.Y + ballSize - 1 >= paddle[0].Y && + ball.Y <= paddle[0].Y + paddleHeight) + { + ballvelocity.X *= -1; + increaseSpeed = true; + } + } + if (ball.X + ballSize >= paddle[1].X && ballvelocity.X > 0) + { + if (ball.Y + ballSize - 1 >= paddle[1].Y && + ball.Y <= paddle[1].Y + paddleHeight) + { + ballvelocity.X *= -1; + increaseSpeed = true; + } + } - if (Keyboard.Keys[KeyCode.Down]) paddle[0].Y += paddleMove; - if (Keyboard.Keys[KeyCode.Up]) paddle[0].Y -= paddleMove; + if (increaseSpeed) + { + ballvelocity.X += Math.Sign(ballvelocity.X) * 10.0f; + ballvelocity.Y += Math.Sign(ballvelocity.Y) * 10.0f; + } + } - // do AI - if (ballvelocity.X > 0) - { - if (ball.Y + ballSize * 2 > paddle[1].Y + paddleHeight) paddle[1].Y += paddleMove; - if (ball.Y - ballSize < paddle[1].Y) paddle[1].Y -= paddleMove; - } + private void UpdatePaddles(float time_s) + { + float paddleMove = paddleSpeed * time_s; - for (int i = 0; i < 2; i++) - { - paddle[i].Y = Math.Max(paddle[i].Y, borderSize); - paddle[i].Y = Math.Min(paddle[i].Y, displayHeight - borderSize - paddleHeight); - } - } + if (Keyboard.Keys[KeyCode.Down]) paddle[0].Y += paddleMove; + if (Keyboard.Keys[KeyCode.Up]) paddle[0].Y -= paddleMove; - private void DrawBall() - { - Display.FillRect(new Rectangle((int)ball.X, (int)ball.Y, ballSize, ballSize), ballColor); - } + // do AI + if (ballvelocity.X > 0) + { + if (ball.Y + ballSize * 2 > paddle[1].Y + paddleHeight) paddle[1].Y += paddleMove; + if (ball.Y - ballSize < paddle[1].Y) paddle[1].Y -= paddleMove; + } - private void DrawPaddles() - { - for (int i = 0; i < 2; i++) - { - Display.FillRect( - new Rectangle((int)paddle[i].X, (int)paddle[i].Y, paddleWidth, paddleHeight), paddleColor); - } - } + for (int i = 0; i < 2; i++) + { + paddle[i].Y = Math.Max(paddle[i].Y, borderSize); + paddle[i].Y = Math.Min(paddle[i].Y, displayHeight - borderSize - paddleHeight); + } + } - private void DrawBorder() - { - Color borderColor = paddleColor; + private void DrawBall() + { + Display.FillRect(new Rectangle((int)ball.X, (int)ball.Y, ballSize, ballSize), ballColor); + } - Display.FillRect(new Rectangle(0, 0, displayWidth, borderSize), borderColor); - Display.FillRect(new Rectangle(0, 0, borderSize, displayHeight), borderColor); - Display.FillRect(new Rectangle(0, displayHeight - borderSize, displayWidth, borderSize), borderColor); - Display.FillRect(new Rectangle(displayWidth - borderSize, 0, borderSize, displayHeight), borderColor); - Display.FillRect(new Rectangle(playAreaWidth - borderSize, 0, borderSize, displayHeight), borderColor); - - } + private void DrawPaddles() + { + for (int i = 0; i < 2; i++) + { + Display.FillRect( + new Rectangle((int)paddle[i].X, (int)paddle[i].Y, paddleWidth, paddleHeight), paddleColor); + } + } - void Mouse_MouseMove(InputEventArgs e) - { - int deltaY = e.MousePosition.Y - displayHeight / 2; + private void DrawBorder() + { + Color borderColor = paddleColor; - paddle[0].Y += deltaY; + Display.FillRect(new Rectangle(0, 0, displayWidth, borderSize), borderColor); + Display.FillRect(new Rectangle(0, 0, borderSize, displayHeight), borderColor); + Display.FillRect(new Rectangle(0, displayHeight - borderSize, displayWidth, borderSize), borderColor); + Display.FillRect(new Rectangle(displayWidth - borderSize, 0, borderSize, displayHeight), borderColor); + Display.FillRect(new Rectangle(playAreaWidth - borderSize, 0, borderSize, displayHeight), borderColor); - Mouse.Position = new Point(displayWidth / 2, displayHeight / 2); - } - } + } + + void Mouse_MouseMove(InputEventArgs e) + { + int deltaY = e.MousePosition.Y - displayHeight / 2; + + paddle[0].Y += deltaY; + + Mouse.Position = new Point(displayWidth / 2, displayHeight / 2); + } + } } \ No newline at end of file Modified: trunk/Examples/Pong/Pong.csproj =================================================================== --- trunk/Examples/Pong/Pong.csproj 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/Pong/Pong.csproj 2014-07-26 15:33:32 UTC (rev 1419) @@ -112,18 +112,14 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Project>{D62BD453-79AC-4A8D-8E75-F85FFF533E4D}</Project> <Name>AgateLib</Name> </ProjectReference> - <ProjectReference Include="..\..\drivers\AgateDrawing\AgateDrawing.csproj"> - <Project>{1AC2AEF6-2EF1-4A8B-8D2D-0480D6EDE65D}</Project> - <Name>AgateDrawing</Name> - </ProjectReference> - <ProjectReference Include="..\..\drivers\AgateOTK\AgateOTK.csproj"> - <Project>{B8476DD4-981E-47CD-A8C2-9E28E84A156D}</Project> - <Name>AgateOTK</Name> - </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Modified: trunk/Examples/ShootTheTraps/App.cs =================================================================== --- trunk/Examples/ShootTheTraps/App.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/ShootTheTraps/App.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -6,6 +6,8 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; using AgateLib.InputLib; +using AgateLib.Platform.WindowsForms.Resources; +using AgateLib.Platform; namespace ShootTheTraps { @@ -37,8 +39,8 @@ protected override void Initialize() { - mFont = FontSurface.AgateSans14; - mLargeFont = FontSurface.AgateSans24; + mFont = BuiltinResources.AgateSans14; + mLargeFont = BuiltinResources.AgateSans24; mBackground = new Surface("Resources/background.png"); Mouse.MouseDown += new InputEventHandler(Mouse_MouseDown); Modified: trunk/Examples/ShootTheTraps/Particle.cs =================================================================== --- trunk/Examples/ShootTheTraps/Particle.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/ShootTheTraps/Particle.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -4,6 +4,7 @@ using AgateLib; using AgateLib.DisplayLib; using AgateLib.Geometry; +using AgateLib.Platform; namespace ShootTheTraps { Modified: trunk/Examples/ShootTheTraps/ShootTheTraps.csproj =================================================================== --- trunk/Examples/ShootTheTraps/ShootTheTraps.csproj 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Examples/ShootTheTraps/ShootTheTraps.csproj 2014-07-26 15:33:32 UTC (rev 1419) @@ -99,14 +99,14 @@ </Compile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Project>{198C4842-0000-0000-0000-000000000000}</Project> <Name>AgateLib</Name> </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateOTK\AgateOTK.csproj"> - <Project>{CAB8A0C1-0000-0000-0000-000000000000}</Project> - <Name>AgateOTK</Name> - </ProjectReference> </ItemGroup> <ItemGroup> <None Include="app.config" /> Modified: trunk/Tools/FontCreator/CreateFont.Designer.cs =================================================================== --- trunk/Tools/FontCreator/CreateFont.Designer.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/CreateFont.Designer.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -62,8 +62,8 @@ this.label7 = new System.Windows.Forms.Label(); this.chkMonospaceNumbers = new System.Windows.Forms.CheckBox(); this.nudNumberWidthAdjust = new System.Windows.Forms.NumericUpDown(); - this.renderTarget = new AgateLib.WinForms.AgateRenderTarget(); - this.zoomRenderTarget = new AgateLib.WinForms.AgateRenderTarget(); + this.renderTarget = new AgateLib.Platform.WindowsForms.WinForms.AgateRenderTarget(); + this.zoomRenderTarget = new AgateLib.Platform.WindowsForms.WinForms.AgateRenderTarget(); ((System.ComponentModel.ISupportInitialize)(this.nudSize)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -550,7 +550,7 @@ #endregion - private AgateLib.WinForms.AgateRenderTarget renderTarget; + private AgateLib.Platform.WindowsForms.WinForms.AgateRenderTarget renderTarget; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.ComboBox cboFamily; @@ -561,7 +561,7 @@ private System.Windows.Forms.CheckBox chkUnderline; private System.Windows.Forms.CheckBox chkStrikeout; private System.Windows.Forms.TextBox txtSampleText; - private AgateLib.WinForms.AgateRenderTarget zoomRenderTarget; + private AgateLib.Platform.WindowsForms.WinForms.AgateRenderTarget zoomRenderTarget; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.CheckBox chkTextRenderer; Modified: trunk/Tools/FontCreator/EditGlyphs.cs =================================================================== --- trunk/Tools/FontCreator/EditGlyphs.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/EditGlyphs.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -7,7 +7,7 @@ using System.Windows.Forms; using System.Xml; using AgateLib.BitmapFont; -using AgateLib.WinForms; +using AgateLib.Platform.WindowsForms.WinForms; using AgateLib.Resources; namespace FontCreator Modified: trunk/Tools/FontCreator/FontCreator.cs =================================================================== --- trunk/Tools/FontCreator/FontCreator.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/FontCreator.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -9,6 +9,7 @@ using AgateLib.BitmapFont; using AgateLib.Geometry; using AgateLib.Resources; +using AgateLib.Platform.WindowsForms; namespace FontCreator { Modified: trunk/Tools/FontCreator/FontCreator.csproj =================================================================== --- trunk/Tools/FontCreator/FontCreator.csproj 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/FontCreator.csproj 2014-07-26 15:33:32 UTC (rev 1419) @@ -126,14 +126,14 @@ </Reference> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Name>AgateLib</Name> <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateDrawing\AgateDrawing.csproj"> - <Project>{164A785D-924E-40FB-A517-D7E677F3B53A}</Project> - <Name>AgateDrawing</Name> - </ProjectReference> <ProjectReference Include="..\NotebookLib\NotebookLib\NotebookLib.csproj"> <Project>{91F57346-B574-4D52-9EB0-AA191B552C94}</Project> <Name>NotebookLib</Name> Modified: trunk/Tools/FontCreator/FontCreatorProgram.cs =================================================================== --- trunk/Tools/FontCreator/FontCreatorProgram.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/FontCreatorProgram.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -1,54 +1,50 @@ -using System; +using AgateLib.Platform.WindowsForms; +using AgateLib.Platform.WindowsForms.ApplicationModels; +using System; using System.Collections.Generic; using System.IO; -using System.Text; using System.Windows.Forms; -using AgateLib; namespace FontCreator { - class FontCreatorProgram - { - static List<string> tempFiles = new List<string>(); + class FontCreatorProgram + { + static List<string> tempFiles = new List<string>(); - /// <summary> - /// The main entry point for the application. - /// </summary> - [STAThread] - static void Main(string[] args) - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); - Directory.CreateDirectory("./images"); + PassiveModel.Run(args, () => + { + Directory.CreateDirectory("./images"); - AgateFileProvider.Images.AddPath("./images"); + Configuration.Images.AddPath("./images"); - using (AgateLib.AgateSetup setup = new AgateLib.AgateSetup(args)) - { - setup.Initialize(true, false, false); - if (setup.WasCanceled) - return; + frmFontCreator frm = new frmFontCreator(); + frm.Show(); - frmFontCreator frm = new frmFontCreator(); - frm.Show(); + Properties.Settings.Default.Reload(); - Properties.Settings.Default.Reload(); + // workaround for bug in mono + bool skipWarning = false; - // workaround for bug in mono - bool skipWarning = false; - try { skipWarning = Properties.Settings.Default.SkipWarning; } catch - {} - + { } + if (skipWarning == false) - { - new frmWarningSplash().ShowDialog(frm); - } + { + new frmWarningSplash().ShowDialog(frm); + } try { @@ -57,17 +53,18 @@ catch { } - Application.Run(frm); - } + Application.Run(frm); - foreach (string file in tempFiles) - { - File.Delete(file); - } - } - public static void RegisterTempFile(string file) - { - tempFiles.Add(file); - } - } + + foreach (string file in tempFiles) + { + File.Delete(file); + } + }); + } + public static void RegisterTempFile(string file) + { + tempFiles.Add(file); + } + } } Modified: trunk/Tools/FontCreator/frmFontCreator.cs =================================================================== --- trunk/Tools/FontCreator/frmFontCreator.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/frmFontCreator.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -7,6 +7,7 @@ using System.Text; using System.Windows.Forms; using AgateLib.BitmapFont; +using AgateLib.Platform.WindowsForms; namespace FontCreator { @@ -18,7 +19,7 @@ { InitializeComponent(); - Icon = AgateLib.WinForms.FormUtil.AgateLibIcon; + Icon = AgateLib.Platform.WindowsForms.WinForms.FormUtil.AgateLibIcon; CurrentPage = 1; } Modified: trunk/Tools/FontCreator/frmWarningSplash.cs =================================================================== --- trunk/Tools/FontCreator/frmWarningSplash.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/FontCreator/frmWarningSplash.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -14,7 +14,7 @@ { InitializeComponent(); - Icon = AgateLib.WinForms.FormUtil.AgateLibIcon; + Icon = AgateLib.Platform.WindowsForms.WinForms.FormUtil.AgateLibIcon; } private void btnOK_Click(object sender, EventArgs e) Modified: trunk/Tools/PackedSpriteCreator/PackedSpriteCreator.csproj =================================================================== --- trunk/Tools/PackedSpriteCreator/PackedSpriteCreator.csproj 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/PackedSpriteCreator/PackedSpriteCreator.csproj 2014-07-26 15:33:32 UTC (rev 1419) @@ -122,14 +122,14 @@ </Reference> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Name>AgateLib</Name> <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateDrawing\AgateDrawing.csproj"> - <Name>AgateDrawing</Name> - <Project>{164A785D-924E-40FB-A517-D7E677F3B53A}</Project> - </ProjectReference> </ItemGroup> <ItemGroup> <Compile Include="frmAddSpriteFrames.cs"> Modified: trunk/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs =================================================================== --- trunk/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -45,7 +45,7 @@ this.txtName = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget(); + this.agateRenderTarget1 = new AgateLib.Platform.WindowsForms.WinForms.AgateRenderTarget(); this.chkAnimating = new System.Windows.Forms.CheckBox(); this.btnNewSprite = new System.Windows.Forms.Button(); this.propertiesPanel.SuspendLayout(); @@ -332,7 +332,7 @@ private System.Windows.Forms.Label label2; private System.Windows.Forms.NumericUpDown nudTimePerFrame; private System.Windows.Forms.Label label3; - private AgateLib.WinForms.AgateRenderTarget agateRenderTarget1; + private AgateLib.Platform.WindowsForms.WinForms.AgateRenderTarget agateRenderTarget1; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.ListBox lstFrames; private System.Windows.Forms.Button btnDelete; Modified: trunk/Tools/PackedSpriteCreator/SpriteEditor.cs =================================================================== --- trunk/Tools/PackedSpriteCreator/SpriteEditor.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/PackedSpriteCreator/SpriteEditor.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -214,7 +214,7 @@ private void btnAdd_Click(object sender, EventArgs e) { frmAddSpriteFrames frm = new frmAddSpriteFrames(); - frm.SpriteSize = AgateLib.WinForms.Interop.Convert(mCurrentSprite.Size); + frm.SpriteSize = AgateLib.Platform.WindowsForms.WinForms.Interop.Convert(mCurrentSprite.Size); if (frm.ShowDialog(this) == DialogResult.OK) { Modified: trunk/Tools/PackedSpriteCreator/SpritePacker.cs =================================================================== --- trunk/Tools/PackedSpriteCreator/SpritePacker.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/PackedSpriteCreator/SpritePacker.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -7,23 +7,19 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; using AgateLib.Resources; +using AgateLib.Platform.WindowsForms.ApplicationModels; namespace PackedSpriteCreator { - class SpriteCreator - { - [STAThread] - static void Main(string[] args) - { - using (AgateSetup setup = new AgateSetup()) - { - setup.InitializeDisplay(AgateLib.Drivers.DisplayTypeID.Reference); - if (setup.WasCanceled) - return; - - System.Windows.Forms.Application.Run(new frmSpriteCreator()); - return; - } - } - } + class SpriteCreator + { + [STAThread] + static void Main(string[] args) + { + PassiveModel.Run(args, () => + { + System.Windows.Forms.Application.Run(new frmSpriteCreator()); + }); + } + } } Modified: trunk/Tools/PackedSpriteCreator/frmSpriteCreator.cs =================================================================== --- trunk/Tools/PackedSpriteCreator/frmSpriteCreator.cs 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/PackedSpriteCreator/frmSpriteCreator.cs 2014-07-26 15:33:32 UTC (rev 1419) @@ -1,4 +1,5 @@ -using System; +using AgateLib.Platform.WindowsForms; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -15,7 +16,7 @@ { InitializeComponent(); - Icon = AgateLib.WinForms.FormUtil.AgateLibIcon; + Icon = AgateLib.Platform.WindowsForms.WinForms.FormUtil.AgateLibIcon; spriteEditor1.Enabled = false; } @@ -43,8 +44,8 @@ System.IO.Directory.SetCurrentDirectory( System.IO.Path.GetDirectoryName(openDialog.FileName)); - AgateLib.AgateFileProvider.Images.Clear(); - AgateLib.AgateFileProvider.Images.AddPath("."); + Configuration.Images.Clear(); + Configuration.Images.AddPath("."); } private void closeResourceFileToolStripMenuItem_Click(object sender, EventArgs e) Modified: trunk/Tools/ResourceEditor/ResourceEditor.csproj =================================================================== --- trunk/Tools/ResourceEditor/ResourceEditor.csproj 2014-07-26 15:17:42 UTC (rev 1418) +++ trunk/Tools/ResourceEditor/ResourceEditor.csproj 2014-07-26 15:33:32 UTC (rev 1419) @@ -125,14 +125,14 @@ </Reference> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj"> + <Project>{4b12561e-d37b-48a1-b6db-218e94906c22}</Project> + <Name>AgateLib.Platform.WindowsForms</Name> + </ProjectReference> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Name>AgateLib</Name> <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project> </ProjectReference> - <ProjectReference Include="..\..\Drivers\AgateDrawing\AgateDrawing.csproj"> - <Name>AgateDrawing</Name> - <Project>{164A785D-924E-40FB-A517-D7E677F3B53A}</Project> - </ProjectReference> <ProjectReference Include="..\NotebookLib\NotebookLib\NotebookLib.csproj"> <Name>NotebookLib</Name> <Project>{91F57346-B574-4D52-9EB0-AA191B552C94}</Project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-26 15:17:51
|
Revision: 1418 http://sourceforge.net/p/agate/code/1418 Author: kanato Date: 2014-07-26 15:17:42 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Some fixes to serialization. Modified Paths: -------------- trunk/AgateLib/Core.cs trunk/AgateLib/Diagnostics/AgateConsole.cs trunk/AgateLib/Drivers/IPlatformFactory.cs trunk/AgateLib/Platform/IStopWatch.cs trunk/AgateLib/Platform/Timing.cs trunk/AgateLib/Serialization/Xle/TypeBinder.cs trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs trunk/AgateLib/Serialization/Xle/XleSerializer.cs trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs trunk/Tests/CoreTests/Timers/frmTimers.cs Added Paths: ----------- trunk/AgateLib.Platform.WindowsForms/Factories/SysIoPath.cs Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Core.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -102,7 +102,7 @@ #region --- Error Reporting --- private static CrossPlatformDebugLevel mCrossPlatform = CrossPlatformDebugLevel.Comment; - private static IStopWatch mTime; + private static IStopwatch mTime; /// <summary> /// Static class which is used to handle all error reports. @@ -327,6 +327,7 @@ mTime = factory.PlatformFactory.CreateStopwatch(); FileSystem.File = factory.PlatformFactory.CreateFile(); + FileSystem.Path = factory.PlatformFactory.CreatePath(); Display.Initialize(factory.DisplayFactory.CreateDisplayImpl()); Audio.Initialize(factory.AudioFactory.CreateAudioImpl()); Modified: trunk/AgateLib/Diagnostics/AgateConsole.cs =================================================================== --- trunk/AgateLib/Diagnostics/AgateConsole.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Diagnostics/AgateConsole.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -52,6 +52,7 @@ if (sInstance != null) return; + sInstance = Core.Factory.PlatformFactory.CreateConsole(); PrivateInitialize(); } Modified: trunk/AgateLib/Drivers/IPlatformFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -10,8 +10,14 @@ { PlatformInfo CreatePlatformInfo(); - IStopWatch CreateStopwatch(); + IStopwatch CreateStopwatch(); IO.IFile CreateFile(); + + Diagnostics.AgateConsole CreateConsole(); + + IO.IPath CreatePath(); + + IEnumerable<System.Reflection.Assembly> GetSerializationSearchAssemblies(Type objectType); } } Modified: trunk/AgateLib/Platform/IStopWatch.cs =================================================================== --- trunk/AgateLib/Platform/IStopWatch.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Platform/IStopWatch.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -2,7 +2,7 @@ namespace AgateLib.Platform { - public interface IStopWatch + public interface IStopwatch { void Dispose(); void ForceResume(); Modified: trunk/AgateLib/Platform/Timing.cs =================================================================== --- trunk/AgateLib/Platform/Timing.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Platform/Timing.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -29,7 +29,7 @@ /// </summary> public static class Timing { - private static IStopWatch mAppTimer; + private static IStopwatch mAppTimer; public delegate void TimerDelegate(); @@ -60,7 +60,7 @@ mAppTimer.Resume(); } - public static IStopWatch CreateStopWatch() + public static IStopwatch CreateStopWatch() { return Core.Factory.PlatformFactory.CreateStopwatch(); } Modified: trunk/AgateLib/Serialization/Xle/TypeBinder.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/TypeBinder.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Serialization/Xle/TypeBinder.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -23,7 +23,7 @@ namespace AgateLib.Serialization.Xle { - class TypeBinder : ITypeBinder + public class TypeBinder : ITypeBinder { public List<Assembly> SearchAssemblies = new List<Assembly>(); @@ -46,30 +46,20 @@ return null; } - internal void AddAssembly(Assembly assembly) + public void AddAssemblies(IEnumerable<Assembly> assemblies) { + foreach (var assembly in assemblies) + AddAssembly(assembly); + } + + public void AddAssembly(Assembly assembly) + { if (assembly == null) throw new ArgumentNullException("assembly cannot be null."); if (SearchAssemblies.Contains(assembly)) return; SearchAssemblies.Add(assembly); - - // TODO: See if this is still required. - - // add names of assemblies referenced by the current assembly. - //Assembly[] loaded = assembly. AppDomain.CurrentDomain.GetAssemblies(); - - //foreach (AssemblyName assname in assembly.GetReferencedAssemblies()) - //{ - // foreach (Assembly ass in loaded) - // { - // AssemblyName thisname = ass.GetName(); - - // if (thisname.FullName == assname.FullName) - // AddAssembly(ass); - // } - //} } } } Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -761,7 +761,7 @@ var attribute = CurrentNode.Attribute(name); if (attribute == null) - return true; + return false; XElement element = CurrentNode.Element(name); Modified: trunk/AgateLib/Serialization/Xle/XleSerializer.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -63,6 +63,9 @@ typeBinder.AddAssembly(objectType.Assembly); typeBinder.AddAssembly(Assembly.GetExecutingAssembly()); + typeBinder.AddAssemblies( + Core.Factory.PlatformFactory.GetSerializationSearchAssemblies(objectType)); + Binder = typeBinder; this.objectType = objectType; Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-26 15:17:42 UTC (rev 1418) @@ -90,6 +90,7 @@ <Compile Include="Factories\PlatformFactory.cs" /> <Compile Include="Factories\SdlFactory.cs" /> <Compile Include="Factories\SysIoFile.cs" /> + <Compile Include="Factories\SysIoPath.cs" /> <Compile Include="PixelBufferExtensions.cs" /> <Compile Include="PlatformImplementation\FileProviderList.cs" /> <Compile Include="PlatformImplementation\FileSystemProvider.cs" /> Modified: trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -1,9 +1,11 @@ -using AgateLib.Drivers; +using AgateLib.Diagnostics; +using AgateLib.Drivers; using AgateLib.IO; using AgateLib.Platform.WindowsForms.PlatformImplementation; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -16,7 +18,7 @@ return new FormsPlatformInfo(); } - public IStopWatch CreateStopwatch() + public IStopwatch CreateStopwatch() { return new DiagnosticsStopwatch(); } @@ -26,5 +28,37 @@ { return new SysIoFile(); } + + + public Diagnostics.AgateConsole CreateConsole() + { + return new AgateConsoleImpl(); + } + + + public IPath CreatePath() + { + return new SysIoPath(); + } + + + public IEnumerable<Assembly> GetSerializationSearchAssemblies(Type objectType) + { + var assembly = Assembly.GetEntryAssembly(); + + yield return assembly; + + // add names of assemblies referenced by the current assembly. + Assembly[] loaded = AppDomain.CurrentDomain.GetAssemblies(); + AssemblyName[] referenced = assembly.GetReferencedAssemblies(); + + foreach (AssemblyName assname in referenced) + { + Assembly ass = loaded.FirstOrDefault(x => x.FullName == assname.FullName); + + if (ass != null) + yield return ass; + } + } } } Added: trunk/AgateLib.Platform.WindowsForms/Factories/SysIoPath.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/Factories/SysIoPath.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsForms/Factories/SysIoPath.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -0,0 +1,42 @@ +using AgateLib.IO; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace AgateLib.Platform.WindowsForms.Factories +{ + class SysIoPath : IPath + { + public string Combine(string p1, string p2) + { + return Path.Combine(p1, p2); + } + + public string GetFileNameWithoutExtension(string filename) + { + return Path.GetFileNameWithoutExtension(filename); + } + + public string GetDirectoryName(string filename) + { + return Path.GetDirectoryName(filename); + } + + public string GetFileName(string p) + { + return Path.GetFileName(p); + } + + public string GetExtension(string filename) + { + return Path.GetExtension(filename); + } + + public string GetTempPath() + { + return Path.GetTempPath(); + } + } +} Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -13,7 +13,7 @@ /// A StopWatch can be paused and reset independently of other /// StopWatches. /// </summary> - public class DiagnosticsStopwatch : IDisposable, AgateLib.Platform.IStopWatch + public class DiagnosticsStopwatch : IDisposable, AgateLib.Platform.IStopwatch { Watch watch = new Watch(); int mPause = 1; Modified: trunk/Tests/CoreTests/Timers/frmTimers.cs =================================================================== --- trunk/Tests/CoreTests/Timers/frmTimers.cs 2014-07-26 14:38:36 UTC (rev 1417) +++ trunk/Tests/CoreTests/Timers/frmTimers.cs 2014-07-26 15:17:42 UTC (rev 1418) @@ -17,7 +17,7 @@ { public partial class frmTimerTester : Form { - IStopWatch timer = Timing.CreateStopWatch(); + IStopwatch timer = Timing.CreateStopWatch(); int start = Environment.TickCount; double deltaTimeSum = 0; int count = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-26 14:38:45
|
Revision: 1417 http://sourceforge.net/p/agate/code/1417 Author: kanato Date: 2014-07-26 14:38:36 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Add generic list sort method. Modified Paths: -------------- trunk/AgateLib/Extensions/Collections/Generic/ListSorting.cs trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs trunk/AgateLib/Serialization/Xle/XleSerializer.cs trunk/UnitTests/UnitTests.csproj Added Paths: ----------- trunk/UnitTests/Extensions/ trunk/UnitTests/Extensions/ListExtensions.cs Modified: trunk/AgateLib/Extensions/Collections/Generic/ListSorting.cs =================================================================== --- trunk/AgateLib/Extensions/Collections/Generic/ListSorting.cs 2014-07-26 07:09:55 UTC (rev 1416) +++ trunk/AgateLib/Extensions/Collections/Generic/ListSorting.cs 2014-07-26 14:38:36 UTC (rev 1417) @@ -19,16 +19,21 @@ { if (list == null) throw new ArgumentNullException("list"); - Comparison<T> comp; + Comparison<T> comp = null; if (typeof(IComparable<T>).IsAssignableFrom(typeof(T))) { - InsertionSort(list, (x, y) => ((IComparable<T>)x).CompareTo(y)); + comp = (x, y) => ((IComparable<T>)x).CompareTo(y); } else if (typeof(IComparable).IsAssignableFrom(typeof(T))) { - InsertionSort(list, (x, y) => ((IComparable)x).CompareTo(y)); + comp = (x, y) => ((IComparable)x).CompareTo(y); } + + if (comp == null) + throw new InvalidOperationException("No comparison method available for " + typeof(T).FullName); + + InsertionSort(list, comp); } /// <summary> /// Provides a sort method for IList<T> objects which @@ -37,6 +42,19 @@ /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="comparison"></param> + public static void InsertionSort<T>(this IList<T> list, IComparer<T> comparer) + { + if (list == null) throw new ArgumentNullException("list"); + + InsertionSort(list, (x, y) => comparer.Compare(x, y)); + } + /// <summary> + /// Provides a sort method for IList<T> objects which + /// is stable, unlike the List<T>.Sort() method. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="list"></param> + /// <param name="comparison"></param> public static void InsertionSort<T>(this IList<T> list, Comparison<T> comparison) { if (list == null) throw new ArgumentNullException("list"); Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 07:09:55 UTC (rev 1416) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 14:38:36 UTC (rev 1417) @@ -1591,7 +1591,7 @@ try { - obj = (IXleSerializable)Activator.CreateInstance(type, true); + obj = (IXleSerializable)Activator.CreateInstance(type); } catch (Exception e) { Modified: trunk/AgateLib/Serialization/Xle/XleSerializer.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-07-26 07:09:55 UTC (rev 1416) +++ trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-07-26 14:38:36 UTC (rev 1417) @@ -21,6 +21,7 @@ using System.IO; using System.Text; using System.Reflection; +using System.Linq; using System.Xml.Linq; using System.Xml; @@ -54,7 +55,7 @@ /// <param name="objectType">The type of the object to serialize.</param> public XleSerializer(Type objectType) { - if (typeof(IXleSerializable).IsAssignableFrom(objectType)) + if (objectType.GetInterfaces().Contains(typeof(IXleSerializable)) == false) throw new ArgumentException("Object type is not IXleSerializable."); var typeBinder = new TypeBinder(); Added: trunk/UnitTests/Extensions/ListExtensions.cs =================================================================== --- trunk/UnitTests/Extensions/ListExtensions.cs (rev 0) +++ trunk/UnitTests/Extensions/ListExtensions.cs 2014-07-26 14:38:36 UTC (rev 1417) @@ -0,0 +1,24 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using AgateLib.Extensions.Collections.Generic; + +namespace AgateLib.UnitTests.Extensions +{ + [TestClass] + public class ListExtensions + { + [TestMethod] + public void SortPrimitives() + { + List<int> li = new List<int> { 1, 6, 2, 3, 8, 10, 9, 7, 4, 5 }; + + Assert.AreEqual(10, li.Count); + + li.InsertionSort(); + + for (int i = 0; i < li.Count; i++) + Assert.AreEqual(i + 1, li[i]); + } + } +} Modified: trunk/UnitTests/UnitTests.csproj =================================================================== --- trunk/UnitTests/UnitTests.csproj 2014-07-26 07:09:55 UTC (rev 1416) +++ trunk/UnitTests/UnitTests.csproj 2014-07-26 14:38:36 UTC (rev 1417) @@ -89,6 +89,7 @@ <ItemGroup> <Compile Include="Core\ConsoleTests.cs" /> <Compile Include="Display\DisplayTests.cs" /> + <Compile Include="Extensions\ListExtensions.cs" /> <Compile Include="Fakes\FakeDisplayDriver.cs" /> <Compile Include="Fakes\FakeDisplayWindow.cs" /> <Compile Include="Fakes\FakeFrameBuffer.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-26 07:10:09
|
Revision: 1416 http://sourceforge.net/p/agate/code/1416 Author: kanato Date: 2014-07-26 07:09:55 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Add application models. Several fixes to get tests working. Reintroduce XLE Serializer. More cleanup to make AgateLib portable. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs trunk/AgateLib/AudioLib/Music.cs trunk/AgateLib/Core.cs trunk/AgateLib/Diagnostics/Log.cs trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs trunk/AgateLib/DisplayLib/DisplayWindow.cs trunk/AgateLib/DisplayLib/PixelBuffer.cs trunk/AgateLib/DisplayLib/Surface.cs trunk/AgateLib/Drivers/IAudioFactory.cs trunk/AgateLib/Drivers/IDisplayFactory.cs trunk/AgateLib/Drivers/IInputFactory.cs trunk/AgateLib/Drivers/IPlatformFactory.cs trunk/AgateLib/IO/FileSystem.cs trunk/AgateLib/IO/IFile.cs trunk/AgateLib/Platform/Timing.cs trunk/AgateLib/Serialization/Xle/TypeBinder.cs trunk/AgateLib/Serialization/Xle/XleSerializationException.cs trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs trunk/AgateLib/Serialization/Xle/XleSerializer.cs trunk/AgateLib/Settings/PersistantSettings.cs trunk/AgateLib.GL/AgateLib.GL.csproj trunk/AgateLib.GL/ContextFB.cs trunk/AgateLib.GL/GL3/FrameBuffer.cs trunk/AgateLib.GL/GL3/GLPrimitiveRenderer.cs trunk/AgateLib.GL/GL_IndexBuffer.cs trunk/AgateLib.GL/IGL_Surface.cs trunk/AgateLib.GL/Legacy/FrameBufferExt.cs trunk/AgateLib.GL/Legacy/FrameBufferReadPixels.cs trunk/AgateLib.GL/Legacy/LegacyPrimitiveRenderer.cs trunk/AgateLib.GL/PrimitiveRenderer.cs trunk/AgateLib.GL/ShaderFactory.cs trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/DesktopGLDisplay.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_DisplayControl.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_GameWindow.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_Surface.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs trunk/AgateLib.Platform.WindowsForms/WinForms/BitmapFontUtil.cs trunk/AgateLib.Platform.WindowsForms/WinForms/Icons.Designer.cs trunk/Drivers/AgateOTK/AgateOTK.csproj trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs trunk/Tests/AudioTests/SoundbufferStopTester.cs trunk/Tests/AudioTests/StreamAudio.cs trunk/Tests/CoreTests/ErrorReport/ErrorReport.cs trunk/Tests/CoreTests/ErrorReport/frmErrorReport.cs trunk/Tests/CoreTests/PersistantSettingsTest.cs trunk/Tests/CoreTests/Resources.cs trunk/Tests/CoreTests/Timers/Timers.cs trunk/Tests/CoreTests/Timers/frmTimers.cs trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs trunk/Tests/DisplayTests/Capabilities/Capabilities.cs trunk/Tests/DisplayTests/Capabilities/frmCapabilities.cs trunk/Tests/DisplayTests/ClipRect.cs trunk/Tests/DisplayTests/ColorTest.cs trunk/Tests/DisplayTests/DisplayWindowEvents.cs trunk/Tests/DisplayTests/FullScreen.cs trunk/Tests/DisplayTests/LargeImage.cs trunk/Tests/DisplayTests/MultipleFramebufferTest.cs trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs trunk/Tests/DisplayTests/PixelBufferMask.cs trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs trunk/Tests/DisplayTests/Prerendered.cs trunk/Tests/DisplayTests/RenderStates/RenderStates.cs trunk/Tests/DisplayTests/RenderTargetContinuous.cs trunk/Tests/DisplayTests/RotatingSpriteTester.cs trunk/Tests/DisplayTests/ScreenCapture.cs trunk/Tests/DisplayTests/SpriteTester/SpriteTester.cs trunk/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs trunk/Tests/DisplayTests/TileTester/TileTester.cs trunk/Tests/DisplayTests/Tiling.cs trunk/Tests/Fonts/BitmapFonts.cs trunk/Tests/Fonts/Builtin.cs trunk/Tests/Fonts/FontAlignment.cs trunk/Tests/Fonts/FontLineTester.cs trunk/Tests/Fonts/Fonts.cs trunk/Tests/Fonts/Kerning.cs trunk/Tests/Fonts/TextLayout.cs trunk/Tests/InputTests/Input/InputTester.cs trunk/Tests/Launcher.cs trunk/Tests/Shaders/CoordinateSystem.cs trunk/Tests/Shaders/Hlsl.cs trunk/Tests/Shaders/Lighting3DTest.cs trunk/Tests/Shaders/LightingTest/LightingTest.cs trunk/Tests/Tests.csproj trunk/Tests/frmLauncher.cs trunk/UnitTests/UnitTests.csproj Added Paths: ----------- trunk/AgateLib/ApplicationModels/ trunk/AgateLib/ApplicationModels/AgateAppModel.cs trunk/AgateLib/ApplicationModels/ModelParameters.cs trunk/AgateLib/Drivers/NullDrivers/ trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs trunk/AgateLib/Drivers/NullDrivers/NullSoundImpl.cs trunk/AgateLib/IO/IFileProvider.cs trunk/AgateLib/Serialization/Xle/CompressionMode.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/ trunk/AgateLib.Platform.WindowsForms/ApplicationModels/FormsModelBase.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/PassiveModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SceneModel.cs trunk/AgateLib.Platform.WindowsForms/ApplicationModels/SerialModel.cs trunk/AgateLib.Platform.WindowsForms/Configuration.cs trunk/AgateLib.Platform.WindowsForms/Factories/ trunk/AgateLib.Platform.WindowsForms/Factories/DisplayFactory.cs trunk/AgateLib.Platform.WindowsForms/Factories/FormsFactory.cs trunk/AgateLib.Platform.WindowsForms/Factories/PlatformFactory.cs trunk/AgateLib.Platform.WindowsForms/Factories/SdlFactory.cs trunk/AgateLib.Platform.WindowsForms/Factories/SysIoFile.cs trunk/AgateLib.Platform.WindowsForms/PixelBufferExtensions.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileProviderList.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FileSystemProvider.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/FormsPlatformInfo.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/TgzFileProvider.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/ZipFileProvider.cs trunk/AgateLib.Platform.WindowsForms/Resources/BuiltinResources.cs trunk/AgateLib.Platform.WindowsForms/SurfaceExtensions.cs Removed Paths: ------------- trunk/AgateLib/Drivers/NullInputImpl.cs trunk/AgateLib/Drivers/NullSoundImpl.cs trunk/AgateLib/IFileProvider.cs trunk/AgateLib/Utility/FileProviderList.cs trunk/AgateLib/Utility/FileSystemProvider.cs trunk/AgateLib.Platform.WindowsForms/FormsPlatformInfo.cs trunk/AgateLib.Platform.WindowsForms/Setup.cs trunk/Tests/ResourceTests/Res032.cs trunk/UnitTests/Fakes/FakeReporter.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/AgateLib.csproj 2014-07-26 07:09:55 UTC (rev 1416) @@ -54,7 +54,6 @@ </PropertyGroup> <ItemGroup> <!-- A reference to the entire .NET Framework is automatically included --> - <Folder Include="Serialization\Xle\" /> </ItemGroup> <ItemGroup> <Compile Include="AgateException.cs"> @@ -66,6 +65,8 @@ <Compile Include="AppInitParameters.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="ApplicationModels\AgateAppModel.cs" /> + <Compile Include="ApplicationModels\ModelParameters.cs" /> <Compile Include="AudioLib\AudioCapsInfo.cs" /> <Compile Include="AudioLib\ImplementationBase\MusicImpl.cs" /> <Compile Include="AudioLib\ImplementationBase\SoundBufferImpl.cs" /> @@ -110,7 +111,7 @@ <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> <Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" /> - <Compile Include="IFileProvider.cs"> + <Compile Include="IO\IFileProvider.cs"> <SubType>Code</SubType> </Compile> <Compile Include="DisplayLib\ImplementationBase\FrameBufferImpl.cs" /> @@ -125,6 +126,24 @@ <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> <Compile Include="Resources\ImageResource.cs" /> + <Compile Include="Serialization\Xle\CompressionMode.cs" /> + <Compile Include="Serialization\Xle\CompressionType.cs" /> + <Compile Include="Serialization\Xle\ITypeBinder.cs" /> + <Compile Include="Serialization\Xle\IXleSerializable.cs" /> + <Compile Include="Serialization\Xle\IXleTypeSerializer.cs" /> + <Compile Include="Serialization\Xle\NumericEncoding.cs" /> + <Compile Include="Serialization\Xle\TypeBinder.cs" /> + <Compile Include="Serialization\Xle\TypeSerializers\PointFSerializer.cs" /> + <Compile Include="Serialization\Xle\TypeSerializers\PointSerializer.cs" /> + <Compile Include="Serialization\Xle\TypeSerializers\RectangleFSerializer.cs" /> + <Compile Include="Serialization\Xle\TypeSerializers\RectangleSerializer.cs" /> + <Compile Include="Serialization\Xle\TypeSerializers\SizeFSerializer.cs" /> + <Compile Include="Serialization\Xle\TypeSerializers\SizeSerializer.cs" /> + <Compile Include="Serialization\Xle\XleSerializationException.cs" /> + <Compile Include="Serialization\Xle\XleSerializationInfo.cs" /> + <Compile Include="Serialization\Xle\XleSerializer.cs" /> + <Compile Include="Serialization\Xle\XleTypeSerializerBase.cs" /> + <Compile Include="Serialization\Xle\XleTypeSerializerCollection.cs" /> <Compile Include="Settings\SettingsGroup.cs" /> <Compile Include="Platform\Timing.cs"> <SubType>Code</SubType> @@ -237,10 +256,10 @@ <Compile Include="DisplayLib\Shaders\Implementation\UniformState.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Drivers\NullInputImpl.cs"> + <Compile Include="Drivers\NullDrivers\NullInputImpl.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Drivers\NullSoundImpl.cs"> + <Compile Include="Drivers\NullDrivers\NullSoundImpl.cs"> <SubType>Code</SubType> </Compile> <Compile Include="Geometry\Color.cs"> @@ -354,18 +373,6 @@ <Compile Include="InputLib\Mouse.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Meshes\Loaders\OBJFileRepresentation.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\ObjFile\OBJFileRepresentation.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\ObjFile\Parser.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\ObjFile\TokenTypes.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Particles\Particle.cs"> <SubType>Code</SubType> </Compile> @@ -450,12 +457,6 @@ <Compile Include="Sprites\SpriteFrame.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Utility\FileProviderList.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Utility\FileSystemProvider.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Settings\PersistantSettings.cs" /> <Compile Include="Utility\Ref.cs"> <SubType>Code</SubType> Added: trunk/AgateLib/ApplicationModels/AgateAppModel.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AgateAppModel.cs (rev 0) +++ trunk/AgateLib/ApplicationModels/AgateAppModel.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -0,0 +1,103 @@ +using AgateLib.DisplayLib; +using AgateLib.Geometry; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.ApplicationModels +{ + public abstract class AgateAppModel + { + #region --- Static Members --- + + public static AgateAppModel Instance { get; private set; } + + public static bool IsAlive + { + get + { + if (Instance == null) + return false; + + if (Instance.window != null) + return Instance.window.IsClosed == false; + + if (Display.CurrentWindow == null) + return false; + + return Display.CurrentWindow.IsClosed == false; + } + } + + #endregion + + DisplayWindow window; + + public AgateAppModel(ModelParameters parameters) + { + Parameters = parameters; + + if (IsAlive) + throw new AgateException("Cannot create a new application model when an existing one is active."); + + Instance = this; + } + + protected int RunModel(Func<int> entryPoint) + { + try + { + Initialize(); + AutoCreateDisplayWindow(); + + int retval = BeginModel(entryPoint); + + return retval; + } + finally + { + if (window != null) + window.Dispose(); + + Dispose(); + } + } + + protected abstract int BeginModel(Func<int> entryPoint); + + private void AutoCreateDisplayWindow() + { + if (Parameters.AutoCreateDisplayWindow == false) + return; + + if (Parameters.CreateFullScreenWindow) + { + window = DisplayWindow.CreateFullScreen( + Parameters.ApplicationName, + GetFullScreenSize()); + } + } + + private Size GetFullScreenSize() + { + if (Parameters.DisplayWindowSize.IsEmpty) + return GetScreenSize(); + + if (Parameters.DisplayWindowSize.Width == 0 ) throw new AgateException("Cannot create a display window with width 0."); + if (Parameters.DisplayWindowSize.Height == 0) throw new AgateException("Cannot create a display window with height 0."); + + return Parameters.DisplayWindowSize; + } + + private Size GetScreenSize() + { + return Display.Caps.ScreenResolution; + } + + protected abstract void Initialize(); + protected abstract void Dispose(); + + public ModelParameters Parameters { get; set; } + } +} Added: trunk/AgateLib/ApplicationModels/ModelParameters.cs =================================================================== --- trunk/AgateLib/ApplicationModels/ModelParameters.cs (rev 0) +++ trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -0,0 +1,44 @@ +using AgateLib.Geometry; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.ApplicationModels +{ + public class ModelParameters + { + string[] args; + + public ModelParameters() + { + CreateFullScreenWindow = true; + } + public ModelParameters(string[] args) : this() + { + Arguments = args; + } + + public string ApplicationName { get; set; } + + public bool AutoCreateDisplayWindow { get; set; } + public Size DisplayWindowSize { get; set; } + public bool CreateFullScreenWindow { get; set; } + + public string[] Arguments + { + get { return args; } + set + { + args = value; + ParseArguments(); + } + } + + private void ParseArguments() + { + } + + } +} Modified: trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -35,26 +35,15 @@ /// </summary> /// <param name="filename"></param> /// <returns></returns> - public virtual SoundBufferImpl CreateSoundBuffer(string filename) - { - using (Stream stream = FileSystem.OpenRead(filename)) - { - return CreateSoundBuffer(stream); - } - } + public abstract SoundBufferImpl CreateSoundBuffer(string filename); /// <summary> /// Creates a MusicImpl object. /// </summary> /// <param name="filename"></param> /// <returns></returns> - public virtual MusicImpl CreateMusic(string filename) - { - using (Stream stream = FileSystem.OpenRead(filename)) - { - return CreateMusic(stream); - } - } + public abstract MusicImpl CreateMusic(string filename); + /// <summary> /// Creates a MusicImpl object. /// </summary> Modified: trunk/AgateLib/AudioLib/Music.cs =================================================================== --- trunk/AgateLib/AudioLib/Music.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/AudioLib/Music.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -29,8 +29,6 @@ { /// <summary> /// A class which performs Music playback. - /// - /// This class should support loading of .ogg and .mid files, at the very least. /// </summary> public sealed class Music { @@ -47,10 +45,7 @@ /// <param name="filename">The name of the file to load.</param> public Music(string filename) { - using (System.IO.Stream s = FileSystem.OpenRead(filename)) - { - impl = Audio.Impl.CreateMusic(s); - } + impl = Audio.Impl.CreateMusic(filename); mFilename = filename; } Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Core.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -29,6 +29,7 @@ using AgateLib.Drivers; using AgateLib.Diagnostics; using AgateLib.IO; +using AgateLib.InputLib; namespace AgateLib { @@ -261,13 +262,13 @@ { if (sWroteHeader == true) { - Stream stream = FileSystem.OpenWrite(ErrorFile, true); + Stream stream = FileSystem.File.OpenWrite(ErrorFile, true); return new StreamWriter(stream); } else { - var stream = FileSystem.OpenWrite(ErrorFile); + var stream = FileSystem.File.OpenWrite(ErrorFile); StreamWriter writer = new StreamWriter(stream); WriteHeader(writer); @@ -325,6 +326,12 @@ mPlatform = factory.PlatformFactory.CreatePlatformInfo(); mTime = factory.PlatformFactory.CreateStopwatch(); + FileSystem.File = factory.PlatformFactory.CreateFile(); + + Display.Initialize(factory.DisplayFactory.CreateDisplayImpl()); + Audio.Initialize(factory.AudioFactory.CreateAudioImpl()); + JoystickInput.Initialize(factory.InputFactory.CreateJoystickInputImpl()); + sInititalized = true; } Modified: trunk/AgateLib/Diagnostics/Log.cs =================================================================== --- trunk/AgateLib/Diagnostics/Log.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Diagnostics/Log.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; @@ -7,9 +8,13 @@ { public static class Log { - internal static void WriteLine(string p) + public static void WriteLine(string message) { - throw new NotImplementedException(); + Debug.WriteLine(message); } + public static void WriteLine(string format, params object[] args) + { + Debug.WriteLine(format, args); + } } } Modified: trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -139,6 +139,11 @@ { get { return Display.Impl.CapsSize(DisplaySizeCaps.MaxSurfaceSize); } } + + public Size ScreenResolution + { + get { return Display.Impl.CapsSize(DisplaySizeCaps.NativeScreenResolution); } + } } /// <summary> @@ -150,6 +155,7 @@ /// Value for getting the maximum supported surface size. /// </summary> MaxSurfaceSize, + NativeScreenResolution, } /// <summary> /// Enum which is used to specify a Caps value which should return a logical value. Modified: trunk/AgateLib/DisplayLib/DisplayWindow.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayWindow.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/DisplayLib/DisplayWindow.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -115,6 +115,18 @@ /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> + public static DisplayWindow CreateFullScreen(string title, Size size) + { + return new DisplayWindow(CreateWindowParams.FullScreen(title, size.Width, size.Height, 32)); + } + /// <summary> + /// Creates a DisplayWindow object which renders to the entire screen, setting + /// the resolution to the value specified. + /// </summary> + /// <param name="title"></param> + /// <param name="width"></param> + /// <param name="height"></param> + /// <returns></returns> public static DisplayWindow CreateFullScreen(string title, int width, int height) { return new DisplayWindow(CreateWindowParams.FullScreen(title, width, height, 32)); Modified: trunk/AgateLib/DisplayLib/PixelBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/PixelBuffer.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/DisplayLib/PixelBuffer.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -172,7 +172,8 @@ mData = new byte[size.Width * size.Height * PixelStride]; - SetData(data, sourceFormat, srcRowStride); + throw new NotImplementedException(); + //SetData(data, sourceFormat, srcRowStride); } /// <summary> @@ -701,94 +702,7 @@ } } - /// <summary> - /// Copies the data from the unmanaged memory pointer passed in into the internal pixel - /// buffer array. Automatic conversion is performed if the format the data - /// is in (indicated by format parameter) differs from the format the - /// pixel buffer is in. - /// </summary> - /// <param name="data"></param> - /// <param name="srcFormat"></param> - /// <param name="srcRowStride"></param> - public void SetData(IntPtr data, PixelFormat srcFormat, int srcRowStride) - { - throw new NotImplementedException(); - //int sourceStride = GetPixelStride(srcFormat); - - //unsafe - //{ - // if (srcFormat == this.PixelFormat) - // { - // // optimized copy for same type of data - // int startIndex = 0; - // int rowLength = sourceStride * Width; - - // IntPtr rowPtr = data; - // byte* dataPtr = (byte*)data; - - // for (int y = 0; y < Height; y++) - // { - // Marshal.Copy(rowPtr, mData, startIndex, rowLength); - - // startIndex += RowStride; - // dataPtr += srcRowStride; - // rowPtr = (IntPtr)dataPtr; - // } - // } - // else - // { - // byte[] srcPixel = new byte[srcRowStride]; - // int destIndex = 0; - // IntPtr rowPtr = data; - // byte* dataPtr = (byte*)data; - // int width = Width; - // int destPixelStride = PixelStride; - - // for (int y = 0; y < Height; y++) - // { - // Marshal.Copy(rowPtr, srcPixel, 0, srcRowStride); - - // // check for common Win32 - OpenGL conversion case - // if (this.PixelFormat == PixelFormat.RGBA8888 && - // srcFormat == PixelFormat.BGRA8888) - // { - // // this setup here is OPTIMIZED. - // // Calling ConvertPixel for each pixel when loading a large - // // image adds about 35% more CPU time to do the conversion. - // // By eliminating the function call and processing this special - // // case here we save some time on image loading. - // int srcIndex = 0; - - // for (int x = 0; x < width; x++) - // { - // mData[destIndex] = srcPixel[srcIndex + 2]; - // mData[destIndex + 1] = srcPixel[srcIndex + 1]; - // mData[destIndex + 2] = srcPixel[srcIndex]; - // mData[destIndex + 3] = srcPixel[srcIndex + 3]; - - // destIndex += destPixelStride; - // srcIndex += sourceStride; - // } - // } - // else - // { - // for (int x = 0; x < width; x++) - // { - // ConvertPixel(mData, destIndex, this.PixelFormat, srcPixel, x * sourceStride, srcFormat); - - // destIndex += destPixelStride; - // } - // } - - // dataPtr += srcRowStride; - // rowPtr = (IntPtr)dataPtr; - // } - // } - //} - } - - /// <summary> /// Creates a new PixelBuffer and copies the data in this PixelBuffer, /// performing automatic conversion. Modified: trunk/AgateLib/DisplayLib/Surface.cs =================================================================== --- trunk/AgateLib/DisplayLib/Surface.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/DisplayLib/Surface.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -90,10 +90,7 @@ if (string.IsNullOrEmpty(filename)) throw new ArgumentNullException("You must supply a file name."); - using (System.IO.Stream s = FileSystem.OpenRead(filename)) - { - mImpl = Display.Impl.CreateSurface(s); - } + mImpl = Display.Impl.CreateSurface(filename); Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent); @@ -692,18 +689,6 @@ /// <summary> - /// Saves the surface to the specified file. - /// - /// Infers the file format from the extension. If there - /// is no extension present or it is unrecognized, PNG is - /// assumed. - /// </summary> - /// <param name="filename">File name to save to.</param> - public void SaveTo(string filename) - { - SaveTo(filename, FormatFromExtension(filename)); - } - /// <summary> /// Saves the surface to the specified file, with the specified /// file format. If the file has an extension such as ".png" or /// ".bmp" than the SaveTo(string) overload is prefered, as it @@ -713,7 +698,7 @@ /// <param name="format">Image format for the target file.</param> public void SaveTo(string filename, ImageFileFormat format) { - mImpl.SaveTo(filename, format); + Impl.SaveTo(filename, format); } /// <summary> @@ -824,37 +809,6 @@ #endregion /// <summary> - /// Returns a value in the ImageFileFormat enum based on the file - /// extension of the given filename. No checks are done to see - /// if that file exists. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - public static ImageFileFormat FormatFromExtension(string filename) - { - string ext = FileSystem.Path.GetExtension(filename); - - switch (ext) - { - case ".bmp": - return ImageFileFormat.Bmp; - - case ".jpg": - case ".jpe": - case ".jpeg": - return ImageFileFormat.Jpg; - - case ".tga": - return ImageFileFormat.Tga; - - case ".png": - default: - return ImageFileFormat.Png; - } - - } - - /// <summary> /// Gets the object which does actual rendering of this surface. /// This may be cast to a surface object in whatever rendering library /// is being used (eg. if using the SDX library, this can be cast Modified: trunk/AgateLib/Drivers/IAudioFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IAudioFactory.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Drivers/IAudioFactory.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -8,5 +8,6 @@ { public interface IAudioFactory { + AudioLib.ImplementationBase.AudioImpl CreateAudioImpl(); } } Modified: trunk/AgateLib/Drivers/IDisplayFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IDisplayFactory.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Drivers/IDisplayFactory.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -8,5 +8,6 @@ { public interface IDisplayFactory { + DisplayLib.ImplementationBase.DisplayImpl CreateDisplayImpl(); } } Modified: trunk/AgateLib/Drivers/IInputFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IInputFactory.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Drivers/IInputFactory.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -8,5 +8,6 @@ { public interface IInputFactory { + InputLib.ImplementationBase.InputImpl CreateJoystickInputImpl(); } } Modified: trunk/AgateLib/Drivers/IPlatformFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -11,5 +11,7 @@ PlatformInfo CreatePlatformInfo(); IStopWatch CreateStopwatch(); + + IO.IFile CreateFile(); } } Copied: trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs (from rev 1411, trunk/AgateLib/Drivers/NullInputImpl.cs) =================================================================== --- trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs (rev 0) +++ trunk/AgateLib/Drivers/NullDrivers/NullInputImpl.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -0,0 +1,50 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; + +using AgateLib.Drivers; +using AgateLib.InputLib.ImplementationBase; + +namespace AgateLib.Drivers.NullDrivers +{ + public class NullInputImpl : InputImpl + { + public override void Initialize() + { + Report("No input driver found. Joysticks will not work."); + } + + public override void Dispose() + { + + } + + public override int JoystickCount + { + get { return 0; } + } + + public override IEnumerable<JoystickImpl> CreateJoysticks() + { + return new List<JoystickImpl>(); + } + } +} Copied: trunk/AgateLib/Drivers/NullDrivers/NullSoundImpl.cs (from rev 1411, trunk/AgateLib/Drivers/NullSoundImpl.cs) =================================================================== --- trunk/AgateLib/Drivers/NullDrivers/NullSoundImpl.cs (rev 0) +++ trunk/AgateLib/Drivers/NullDrivers/NullSoundImpl.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -0,0 +1,178 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; + +using AgateLib.Drivers; +using AgateLib.AudioLib.ImplementationBase; + +namespace AgateLib.Drivers.NullDrivers +{ + public class NullSoundImpl : AudioImpl + { + class NullSoundBufferImpl : SoundBufferImpl + { + public override void Dispose() + { + + } + public override double Volume + { + get + { + return 0; + } + set + { + + } + } + + } + public class NullSoundBufferSessionImpl : SoundBufferSessionImpl + { + public override void Dispose() + { + } + public override void Play() + { + } + public override void Stop() + { + } + public override double Volume + { + get + { + return 0; + } + set + { + + } + } + public override double Pan + { + get + { + return 0; + } + set + { + + } + } + public override bool IsPlaying + { + get { return false; } + } + + public override int CurrentLocation + { + get { return 0; } + } + + protected internal override void Initialize() + { + } + + public override bool IsPaused { get; set; } + } + public class NullMusicImpl : MusicImpl + { + protected override void OnSetLoop(bool value) + { + + } + public override void Dispose() + { + + } + public override void Play() + { + + } + public override void Stop() + { + + } + public override double Volume + { + get + { + return 0; + } + set + { + + } + } + public override double Pan + { + get + { + return 0; + } + set + { + + } + } + public override bool IsPlaying + { + get { return false; } + } + } + public override void Initialize() + { + Report("No audio driver found. Audio will not be heard."); + } + + public override void Dispose() + { + } + + public override SoundBufferImpl CreateSoundBuffer(string filename) + { + return new NullSoundBufferImpl(); + } + public override SoundBufferImpl CreateSoundBuffer(System.IO.Stream inStream) + { + return new NullSoundBufferImpl(); + } + public override MusicImpl CreateMusic(string filename) + { + return new NullMusicImpl(); + } + public override SoundBufferSessionImpl CreateSoundBufferSession(SoundBufferImpl buffer) + { + return new NullSoundBufferSessionImpl(); + } + public override MusicImpl CreateMusic(System.IO.Stream musicStream) + { + return new NullMusicImpl(); + } + + protected internal override bool CapsBool(AgateLib.AudioLib.AudioBoolCaps audioBoolCaps) + { + return false; + } + } +} Deleted: trunk/AgateLib/Drivers/NullInputImpl.cs =================================================================== --- trunk/AgateLib/Drivers/NullInputImpl.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Drivers/NullInputImpl.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -1,50 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; - -using AgateLib.Drivers; -using AgateLib.InputLib.ImplementationBase; - -namespace AgateLib.Drivers -{ - class NullInputImpl : InputImpl - { - public override void Initialize() - { - Report("No input driver found. Joysticks will not work."); - } - - public override void Dispose() - { - - } - - public override int JoystickCount - { - get { return 0; } - } - - public override IEnumerable<JoystickImpl> CreateJoysticks() - { - return new List<JoystickImpl>(); - } - } -} Deleted: trunk/AgateLib/Drivers/NullSoundImpl.cs =================================================================== --- trunk/AgateLib/Drivers/NullSoundImpl.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Drivers/NullSoundImpl.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -1,178 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; - -using AgateLib.Drivers; -using AgateLib.AudioLib.ImplementationBase; - -namespace AgateLib.Drivers -{ - class NullSoundImpl : AudioImpl - { - class NullSoundBufferImpl : SoundBufferImpl - { - public override void Dispose() - { - - } - public override double Volume - { - get - { - return 0; - } - set - { - - } - } - - } - public class NullSoundBufferSessionImpl : SoundBufferSessionImpl - { - public override void Dispose() - { - } - public override void Play() - { - } - public override void Stop() - { - } - public override double Volume - { - get - { - return 0; - } - set - { - - } - } - public override double Pan - { - get - { - return 0; - } - set - { - - } - } - public override bool IsPlaying - { - get { return false; } - } - - public override int CurrentLocation - { - get { return 0; } - } - - protected internal override void Initialize() - { - } - - public override bool IsPaused { get; set; } - } - public class NullMusicImpl : MusicImpl - { - protected override void OnSetLoop(bool value) - { - - } - public override void Dispose() - { - - } - public override void Play() - { - - } - public override void Stop() - { - - } - public override double Volume - { - get - { - return 0; - } - set - { - - } - } - public override double Pan - { - get - { - return 0; - } - set - { - - } - } - public override bool IsPlaying - { - get { return false; } - } - } - public override void Initialize() - { - Report("No audio driver found. Audio will not be heard."); - } - - public override void Dispose() - { - } - - public override SoundBufferImpl CreateSoundBuffer(string filename) - { - return new NullSoundBufferImpl(); - } - public override SoundBufferImpl CreateSoundBuffer(System.IO.Stream inStream) - { - return new NullSoundBufferImpl(); - } - public override MusicImpl CreateMusic(string filename) - { - return new NullMusicImpl(); - } - public override SoundBufferSessionImpl CreateSoundBufferSession(SoundBufferImpl buffer) - { - return new NullSoundBufferSessionImpl(); - } - public override MusicImpl CreateMusic(System.IO.Stream musicStream) - { - return new NullMusicImpl(); - } - - protected internal override bool CapsBool(AgateLib.AudioLib.AudioBoolCaps audioBoolCaps) - { - return false; - } - } -} Deleted: trunk/AgateLib/IFileProvider.cs =================================================================== --- trunk/AgateLib/IFileProvider.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/IFileProvider.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -1,82 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace AgateLib -{ - /// <summary> - /// Public interface that should be implemented - /// </summary> - public interface IFileProvider - { - /// <summary> - /// Opens the specified file returning a stream. Throws - /// FileNotFoundException if the file does not exist. - /// </summary> - /// <param name="filename">The path and filename of the file to read from.</param> - /// <returns></returns> - Stream OpenRead(string filename); - /// <summary> - /// Checks to if the specified file exists in the file provider. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - bool FileExists(string filename); - - /// <summary> - /// Enumerates through all filenames in the file provider. - /// </summary> - /// <returns></returns> - IEnumerable<string> GetAllFiles(); - /// <summary> - /// Enumerates through all filenames which match the specified search pattern. - /// </summary> - /// <remarks>The search pattern is not regex style pattern matching, rather it should - /// be bash pattern matching, so a searchPattern of "*" would match all files, and - /// "*.*" would match all filenames with a period in them.</remarks> - /// <param name="searchPattern"></param> - /// <returns></returns> - IEnumerable<string> GetAllFiles(string searchPattern); - /// <summary> - /// Returns a string containing the entire contents of the specified file. - /// </summary> - /// <param name="filename">The path and filename of the file to read from.</param> - /// <returns></returns> - string ReadAllText(string filename); - - /// <summary> - /// Returns true if the specified filename points to an actual file on disk. - /// If this method returns false, then ResolveFile will throw an exception - /// for that file. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - bool IsRealFile(string filename); - - /// <summary> - /// Returns the full path of the given filename. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - string ResolveFile(string filename); - } -} Modified: trunk/AgateLib/IO/FileSystem.cs =================================================================== --- trunk/AgateLib/IO/FileSystem.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/IO/FileSystem.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -8,19 +8,8 @@ { public static class FileSystem { - public static Stream OpenRead(string filename) - { - throw new NotImplementedException(); - } - public static Stream OpenWrite(string ErrorFile, bool append = false) - { - throw new NotImplementedException(); - } - - public static IFile File { get; set; } public static IPath Path { get; set; } public static IDirectory Directory { get; set; } - } } Modified: trunk/AgateLib/IO/IFile.cs =================================================================== --- trunk/AgateLib/IO/IFile.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/IO/IFile.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -8,5 +8,8 @@ public interface IFile { bool Exists(string path); + + System.IO.Stream OpenRead(string filename); + System.IO.Stream OpenWrite(string filename, bool append = false); } } Copied: trunk/AgateLib/IO/IFileProvider.cs (from rev 1411, trunk/AgateLib/IFileProvider.cs) =================================================================== --- trunk/AgateLib/IO/IFileProvider.cs (rev 0) +++ trunk/AgateLib/IO/IFileProvider.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -0,0 +1,82 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace AgateLib +{ + /// <summary> + /// Public interface that should be implemented + /// </summary> + public interface IFileProvider + { + /// <summary> + /// Opens the specified file returning a stream. Throws + /// FileNotFoundException if the file does not exist. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + Stream OpenRead(string filename); + /// <summary> + /// Checks to if the specified file exists in the file provider. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + bool FileExists(string filename); + + /// <summary> + /// Enumerates through all filenames in the file provider. + /// </summary> + /// <returns></returns> + IEnumerable<string> GetAllFiles(); + /// <summary> + /// Enumerates through all filenames which match the specified search pattern. + /// </summary> + /// <remarks>The search pattern is not regex style pattern matching, rather it should + /// be bash pattern matching, so a searchPattern of "*" would match all files, and + /// "*.*" would match all filenames with a period in them.</remarks> + /// <param name="searchPattern"></param> + /// <returns></returns> + IEnumerable<string> GetAllFiles(string searchPattern); + /// <summary> + /// Returns a string containing the entire contents of the specified file. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + string ReadAllText(string filename); + + /// <summary> + /// Returns true if the specified filename points to an actual file on disk. + /// If this method returns false, then ResolveFile will throw an exception + /// for that file. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + bool IsRealFile(string filename); + + /// <summary> + /// Returns the full path of the given filename. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + string ResolveFile(string filename); + } +} Modified: trunk/AgateLib/Platform/Timing.cs =================================================================== --- trunk/AgateLib/Platform/Timing.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Platform/Timing.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -56,7 +56,15 @@ //Console.WriteLine(" Timer is accurate within {0} nanoseconds", // nanosecPerTick); + mAppTimer = CreateStopWatch(); + mAppTimer.Resume(); } + + public static IStopWatch CreateStopWatch() + { + return Core.Factory.PlatformFactory.CreateStopwatch(); + } + /// <summary> /// Returns the number of seconds since the application started. /// </summary> Added: trunk/AgateLib/Serialization/Xle/CompressionMode.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/CompressionMode.cs (rev 0) +++ trunk/AgateLib/Serialization/Xle/CompressionMode.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.Serialization.Xle +{ + enum CompressionMode + { + Compress, + Decompress + } +} Modified: trunk/AgateLib/Serialization/Xle/TypeBinder.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/TypeBinder.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Serialization/Xle/TypeBinder.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -55,19 +55,21 @@ SearchAssemblies.Add(assembly); + // TODO: See if this is still required. + // add names of assemblies referenced by the current assembly. - Assembly[] loaded = AppDomain.CurrentDomain.GetAssemblies(); + //Assembly[] loaded = assembly. AppDomain.CurrentDomain.GetAssemblies(); - foreach (AssemblyName assname in assembly.GetReferencedAssemblies()) - { - foreach (Assembly ass in loaded) - { - AssemblyName thisname = ass.GetName(); + //foreach (AssemblyName assname in assembly.GetReferencedAssemblies()) + //{ + // foreach (Assembly ass in loaded) + // { + // AssemblyName thisname = ass.GetName(); - if (thisname.FullName == assname.FullName) - AddAssembly(ass); - } - } + // if (thisname.FullName == assname.FullName) + // AddAssembly(ass); + // } + //} } } } Modified: trunk/AgateLib/Serialization/Xle/XleSerializationException.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationException.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Serialization/Xle/XleSerializationException.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -25,7 +25,6 @@ /// <summary> /// Exception thrown when there is a problem in the XleSerializer. /// </summary> - [global::System.Serializable] public class XleSerializationException : Exception { // @@ -38,14 +37,5 @@ internal XleSerializationException() { } internal XleSerializationException(string message) : base(message) { } internal XleSerializationException(string message, Exception inner) : base(message, inner) { } - /// <summary> - /// Constructs an XleSerializationException object when deserializing it. - /// </summary> - /// <param name="info"></param> - /// <param name="context"></param> - protected XleSerializationException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } } Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-25 01:57:36 UTC (rev 1415) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2014-07-26 07:09:55 UTC (rev 1416) @@ -19,11 +19,11 @@ using System; using System.Collections.Generic; using System.IO; -using System.IO.Compression; using System.Linq; using System.Text; using System.Xml.Linq; using System.Runtime.InteropServices; +using System.Globalization; namespace AgateLib.Serialization.Xle { @@ -127,7 +127,7 @@ /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> public void Write(string name, double value, bool asAttribute = false) { - WriteImpl(name, value, asAttribute); + WriteImpl(name, value.ToString(), asAttribute); } /// <summary> /// Writes a field to the XML data as an element or an attribute. @@ -135,19 +135,9 @@ /// <param name="name">The name of the XML element used.</param> /// <param name="value">The value to write.</param> /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> - public void Write(string name, float value, bool asAttribute = false) - { - WriteImpl(name, value, asAttribute); - } - /// <summary> - /// Writes a field to the XML data as an element or an attribute. - /// </summary> - /// <param name="name">The name of the XML element used.</param> - /// <param name="value">The value to write.</param> - /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> public void Write(string name, bool value, bool asAttribute = false) { - WriteImpl(name, value, asAttribute); + WriteImpl(name, value.ToString(), asAttribute); } /// <summary> /// Writes a field to the XML data as an element or an attribute. @@ -157,7 +147,7 @@ /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> public void Write(string name, char value, bool asAttribute = false) { - WriteImpl(name, value, asAttribute); + WriteImpl(name, value.ToString(), asAttribute); } /// <summary> /// Writes a field to the XML data as an element or an attribute. @@ -165,19 +155,9 @@ /// <param name="name">The name of the XML element used.</param> /// <param name="value">The value to write.</param> /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> - public void Write(string name, short value, bool asAttribute = false) - { - WriteImpl(name, value, asAttribute); - } - /// <summary> - /// Writes a field to the XML data as an element or an attribute. - /// </summary> - /// <param name="name">The name of the XML element used.</param> - /// <param name="value">The value to write.</param> - /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> public void Write(string name, int value, bool asAttribute = false) { - WriteImpl(name, value, asAttribute); + WriteImpl(name, value.ToString(), asAttribute); } /// <summary> /// Writes a field to the XML data as an element or an attribute. @@ -187,7 +167,7 @@ /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> public void Write(string name, long value, bool asAttribute = false) { - WriteImpl(name, value, asAttribute); + WriteImpl(name, value.ToString(), asAttribute); } /// <summary> /// Writes a field to the XML data as an element or an attribute. @@ -197,14 +177,14 @@ /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param> public void Write(string name, decimal value, bool asAttribute = false) { - WriteImpl(name, value, asAttribute); + WriteImpl(name, value.ToString(), asAttribute); } - void WriteImpl<T>(string name, T value, bool asAttribute = false) where T : IConvertible + void WriteImpl(string name, string value, bool asAttribute = false) { if (asAttribute) { - WriteAsAttribute<T>(name, value); + WriteAsAttribute(name, value); } else WriteAsElement(name, value); @@ -225,28 +205,28 @@ if (value == null) AddAttribute(CurrentNode, name, "null"); else - WriteAsAttribute(name, (T)value); + WriteAsAttribute(name, ((T)value).ToString()); } else { if (value == null) WriteAsElement(name, "null"); else - WriteAsElement(name, (T)value); + WriteAsElement(name, ((T)value).ToString()); } } - private XElement WriteAsElement<T>(string name, T value) where T : IConvertible + private XElement WriteAsElement(string name, string value) { XElement element = CreateElement(name); - element.Value = value.ToString(); + element.Value = value; return element; } - private void WriteAsAttribute<T>(string name, T value) where T : IConvertible + private void WriteAsAttribute(string name, string value) { - AddAttribute(CurrentNode, name, Convert.ToString(value)); + AddAttribute(CurrentNode, name, value); } private XElement CreateElement(string name) @@ -293,11 +273,13 @@ if (array.Length > 0) { - unsafe + for (int j = 0; j < value.Length; j++) { - fixed (int* val = value) + var bytes = BitConverter.GetBytes(value[j]); + + for (int i = 0; i < bytes.Length; i++) { - Marshal.Copy((IntPtr)val, array, 0, array.Length); + array[j * 4 + i] = bytes[i]; } } } @@ -306,13 +288,8 @@ break; case NumericEncoding.Csv: - string newValue = string.Join(",", value.Select(x => x.ToString()).ToArray()); + WriteAsCsv(name, value); - XElement el = WriteAsElement(name, newValue); - - AddAttribute(el, "array", "true"); - AddAttribute(el, "encoding", "Csv"); - break; default: @@ -320,6 +297,20 @@ } } + private void WriteAsCsv<T>(string name, IEnumerable<T> value) + { + WriteAsCsv(name, value, x => x.ToString()); + } + private void WriteAsCsv<T>(string name, IEnumerable<T> value, Func<T, string> converter) + { + string newValue = string.Join(",", value.Select(x => converter(x)).ToArray()); + + XElement el = WriteAsElement(name, newValue); + + AddAttribute(el, "array", "true"); + AddAttribute(el, "encoding", "Csv"); + } + /// <summary> /// Writes a bool[] array to the XML data as an element. /// </summary> @@ -327,12 +318,7 @@ /// <param name="value">The array data to write.</param> public void Write(string name, bool[] value) { - byte[] array = new byte[value.Length]; - - for (int i = 0; i < value.Length; i++) - array[i] = (byte)(value[i] ? 1 : 0); - - WriteBase64Encoded(name, array); + WriteAsCsv(name, value); } /// <summary> @@ -342,17 +328,7 @@ /// <param name="value">The array data to write.</param> public void Write(string name, double[] value) { - byte[] array = new byte[value.Length * 8]; - - unsafe - { - fixed (double* val = value) - { - Marshal.Copy((IntPtr)val, array, 0, array.Length); - } - } - - WriteBase64Encoded(name, array); + WriteAsCsv(name, value); } /// <summary> @@ -362,12 +338,12 @@ /// <param name="value">The array data to write.</param> public void Write(string name, byte[] value) { - WriteBase64Encoded(name, value); + WriteAsCsv(name, value); } private void WriteBase64Encoded(string name, byte[] value) { - string newValue = Convert.ToBase64String(value, Base64FormattingOptions.InsertLineBreaks); + string newValue = Convert.ToBase64String(value); XElement el = WriteAsElement(name, newValue); @@ -624,17 +600,23 @@ private void WriteImpl(string name, Stream value, CompressionType compression) { - MemoryStream ms = new MemoryStream(); - Stream compressed = TranslateStream(ms, compression, CompressionMode.Compress); + if (compression != CompressionType.None) + { + MemoryStream ms = new MemoryStream(); + Stream compressed = TranslateStream(ms, compression, CompressionMode.Compress); - byte[] uncompressedData = ReadFromStream(value); - compressed.Write(uncompressedData, 0, uncompressedData.Length); + byte[] uncompressedData = ReadFromStream(value); + compressed.Write(uncompressedData, 0, uncompressedData.Length); - byte[] buffer = ms.GetBuffer(); + value = ms; + value.Seek(0, SeekOrigin.Begin); + } - string newValue = Convert.ToBase64String( - buffer/*, Base64FormattingOptions.InsertLineBreaks*/); + byte[] buffer = new byte[value.Length]; + value.Read(buffer, 0, (int)value.Length); + string newValue = Convert.ToBase64String(buffer); + XElement el = WriteAsElement(name, newValue); AddAttribute(el, "stream", "true"); AddAttribute(el, "compression", compression.ToString()); @@ -994,7 +976,7 @@ if (typeof(T).IsEnum == false) throw new XleSerializationException("Type passed is not an enum."); - return (T)Enum.Parse(typeof(T), ReadStringImpl(name, false, string.Empty)); + return (T)Enum.Parse(typeof(T), ReadStringImpl(name, false, string.Empty), true); } /// <summary> /// Reads an enum field from the XML data. @@ -1007,7 +989,7 @@ if (typeof(T).IsEnum == false) throw new XleSerializationException("Type passed is not an enum."); - return (T)Enum.Parse(typeof(T), ReadStringImpl(name, true, defaultValue.ToString())); + return (T)Enum.Parse(typeof(T), ReadStringImpl(name, true, defaultValue.ToString()), true); } /// <summary> @@ -1055,7 +1037,7 @@ #endregion #region --- Reading array values --- - private string GetEncoding(string name) + private NumericEncoding GetEncoding(string name) { XElement element = CurrentNode.Element(name); @@ -1064,7 +1046,7 @@ if (element.Attribute("encoding") == null) throw new XleSerializationException("Element " + name + " does not have encoding information."); - ... [truncated message content] |
From: <ka...@us...> - 2014-07-25 01:57:40
|
Revision: 1415 http://sourceforge.net/p/agate/code/1415 Author: kanato Date: 2014-07-25 01:57:36 +0000 (Fri, 25 Jul 2014) Log Message: ----------- AgateLib.dll is now portable. Tests don't compile yet. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib-Windows.sln trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj trunk/Tests/CoreTests/Timers/frmTimers.cs trunk/Tests/Tests.csproj trunk/Tests/frmLauncher.cs Removed Paths: ------------- trunk/AgateLib/AgateLib-Portable.csproj trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.Designer.cs trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.cs trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.resx trunk/AgateLib.Platform.WindowsForms/WinForms/WinFormsDriver.cs trunk/AgateLib.Platform.WindowsForms/WinForms/WinFormsReporter.cs Deleted: trunk/AgateLib/AgateLib-Portable.csproj =================================================================== --- trunk/AgateLib/AgateLib-Portable.csproj 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib/AgateLib-Portable.csproj 2014-07-25 01:57:36 UTC (rev 1415) @@ -1,480 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{DB2152AD-E467-40A2-94E8-EB3804863C71}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>AgateLib</RootNamespace> - <AssemblyName>AgateLib</AssemblyName> - <DefaultLanguage>en-US</DefaultLanguage> - <FileAlignment>512</FileAlignment> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <TargetFrameworkProfile>Profile344</TargetFrameworkProfile> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <RunCodeAnalysis>false</RunCodeAnalysis> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> - <DebugSymbols>true</DebugSymbols> - <OutputPath>bin\x86\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <DebugType>full</DebugType> - <PlatformTarget>x86</PlatformTarget> - <ErrorReport>prompt</ErrorReport> - <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> - <OutputPath>bin\x86\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <Optimize>true</Optimize> - <DebugType>pdbonly</DebugType> - <PlatformTarget>x86</PlatformTarget> - <ErrorReport>prompt</ErrorReport> - <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <ItemGroup> - <!-- A reference to the entire .NET Framework is automatically included --> - <Folder Include="Serialization\Xle\" /> - </ItemGroup> - <ItemGroup> - <Compile Include="AgateException.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AgateGame.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AppInitParameters.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AudioLib\AudioCapsInfo.cs" /> - <Compile Include="AudioLib\ImplementationBase\MusicImpl.cs" /> - <Compile Include="AudioLib\ImplementationBase\SoundBufferImpl.cs" /> - <Compile Include="AudioLib\ImplementationBase\SoundBufferSessionImpl.cs" /> - <Compile Include="AudioLib\ImplementationBase\StreamingSoundBufferImpl.cs" /> - <Compile Include="AudioLib\SoundFormat.cs" /> - <Compile Include="AudioLib\StreamingSoundBuffer.cs" /> - <Compile Include="Core.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Diagnostics\AgateConsole.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\AgateConsoleCommandProcessor.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\ConsoleDictionary.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessage.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessageType.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\DescriptionAttribute.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\ICommandProcessor.cs" /> - <Compile Include="Diagnostics\Log.cs" /> - <Compile Include="DisplayLib\FrameBuffer.cs" /> - <Compile Include="DisplayLib\IFrameBuffer.cs" /> - <Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" /> - <Compile Include="DisplayLib\Shaders\AgateShaderCompileException.cs" /> - <Compile Include="DisplayLib\Shaders\Basic2DShader.cs" /> - <Compile Include="DisplayLib\Shaders\AgateShader.cs" /> - <Compile Include="DisplayLib\Shaders\Implementation\AgateInternalShader.cs" /> - <Compile Include="DisplayLib\Shaders\Implementation\AgateShaderImpl.cs" /> - <Compile Include="DisplayLib\Shaders\Implementation\Basic2DImpl.cs" /> - <Compile Include="DisplayLib\Shaders\Implementation\BuiltInShader.cs" /> - <Compile Include="DisplayLib\Shaders\Implementation\Lighting2DImpl.cs" /> - <Compile Include="DisplayLib\Shaders\Implementation\Lighting3DImpl.cs" /> - <Compile Include="DisplayLib\Shaders\Lighting2D.cs" /> - <Compile Include="DisplayLib\Shaders\Lighting3D.cs" /> - <Compile Include="Drivers\DriverImplBase.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\IAgateFactory.cs" /> - <Compile Include="Drivers\IAudioFactory.cs" /> - <Compile Include="Drivers\IDisplayFactory.cs" /> - <Compile Include="Drivers\IInputFactory.cs" /> - <Compile Include="Drivers\IPlatformFactory.cs" /> - <Compile Include="Drivers\TypeRegistry.cs" /> - <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> - <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> - <Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" /> - <Compile Include="IFileProvider.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\FrameBufferImpl.cs" /> - <Compile Include="InputLib\Delegates.cs" /> - <Compile Include="InputLib\HatState.cs" /> - <Compile Include="InputLib\JoystickEventArgs.cs" /> - <Compile Include="IO\FileSystem.cs" /> - <Compile Include="IO\IDirectory.cs" /> - <Compile Include="IO\IFile.cs" /> - <Compile Include="IO\IPath.cs" /> - <Compile Include="Platform\IStopWatch.cs" /> - <Compile Include="Platform\PlatformInfo.cs" /> - <Compile Include="Platform\PlatformType.cs" /> - <Compile Include="Resources\ImageResource.cs" /> - <Compile Include="Settings\SettingsGroup.cs" /> - <Compile Include="Platform\Timing.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AudioLib\Audio.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AudioLib\Music.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AudioLib\SoundBuffer.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AudioLib\SoundBufferSession.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="BitmapFont\BitmapFontImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="BitmapFont\BitmapFontOptions.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="BitmapFont\FontMetrics.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="BitmapFont\GlyphMetrics.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\CreateWindowParams.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Display.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\DisplayCapsInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\DisplayWindow.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\FontState.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\FontSurface.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\IndexBuffer.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ISurface.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Origin.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\OriginAlignment.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\PixelBuffer.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\PixelFormat.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\PrimitiveType.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\RenderStateAdapter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ScreenMode.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\StringTransformer.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Surface.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\SurfaceState.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\TextLayout.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\VertexBuffer.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Cache\FontStateCache.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Cache\SurfaceStateCache.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\Effect.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\ShaderCompiler.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\ShaderLanguage.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\ShaderProgram.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\Technique.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\UniformState.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\NullInputImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\NullSoundImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Color.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Gradient.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Matrix4x4.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Point.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\PointF.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Rectangle.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\RectangleF.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Size.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\SizeF.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Vector2.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Vector3.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Vector4.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Builders\Cube.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\Builders\Terrain.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\VertexTypes\PositionColor.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\VertexTypes\PositionTextureColor.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\VertexTypes\PositionTextureNormal.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\VertexTypes\PositionTextureNormalTangent.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\VertexTypes\PositionTextureNTB.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Geometry\VertexTypes\VertexLayout.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="AudioLib\ImplementationBase\AudioImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\DisplayImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\DisplayWindowImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\FontSurfaceImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\IndexBufferImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\ImplementationBase\InputImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\ImplementationBase\JoystickImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\ShaderCompilerImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\SurfaceImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\ImplementationBase\VertexBufferImpl.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\InputEventArgs.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\Joystick.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\JoystickInput.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\Keyboard.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\KeyCode.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\KeyModifiers.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InputLib\Mouse.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\OBJFileRepresentation.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\ObjFile\OBJFileRepresentation.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\ObjFile\Parser.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Meshes\Loaders\ObjFile\TokenTypes.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Particle.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\ParticleEmitter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Emitters\PixelEmitter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Emitters\SpriteEmitter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Emitters\SurfaceEmitter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Manipulators\FadeOutManipulator.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Manipulators\GravityManipulator.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Manipulators\GravityPointManipulator.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Particles\PixelParticle.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Particles\SpriteParticle.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Particles\Particles\SurfaceParticle.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Properties\AssemblyInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\AgateResource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\AgateResourceCollection.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\AgateResourceException.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\AgateResourceLoader.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\BitmapFontResource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\DisplayWindowResource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\SpriteResource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\StringTable.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\SurfaceResource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Resources\XmlHelper.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Sprites\FrameList.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Sprites\IFrameList.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Sprites\ISprite.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Sprites\ISpriteFrame.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Sprites\Sprite.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Sprites\SpriteFrame.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Utility\FileProviderList.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Utility\FileSystemProvider.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Settings\PersistantSettings.cs" /> - <Compile Include="Utility\Ref.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Utility\SurfacePacker.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="DisplayLib\Shaders\IShader2D.cs" /> - <Compile Include="Settings\ISettingsTracer.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="packages.config" /> - </ItemGroup> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> \ No newline at end of file Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib/AgateLib.csproj 2014-07-25 01:57:36 UTC (rev 1415) @@ -1,142 +1,68 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0"> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> - <ProjectType>Local</ProjectType> - <ProductVersion>9.0.21022</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{9490B719-829E-43A7-A5FE-8001F8A81759}</ProjectGuid> + <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <AssemblyKeyContainerName> - </AssemblyKeyContainerName> - <AssemblyName>AgateLib</AssemblyName> - <DefaultClientScript>JScript</DefaultClientScript> - <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> - <DefaultTargetSchema>IE50</DefaultTargetSchema> - <DelaySign>false</DelaySign> - <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> + <ProjectGuid>{9490B719-829E-43A7-A5FE-8001F8A81759}</ProjectGuid> <OutputType>Library</OutputType> - <AppDesignerFolder> - </AppDesignerFolder> + <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>AgateLib</RootNamespace> - <FileUpgradeFlags> - </FileUpgradeFlags> - <OldToolsVersion>3.5</OldToolsVersion> - <UpgradeBackupLocation /> - <TargetFrameworkProfile /> + <AssemblyName>AgateLib</AssemblyName> + <DefaultLanguage>en-US</DefaultLanguage> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <TargetFrameworkProfile>Profile344</TargetFrameworkProfile> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <BaseAddress>285212672</BaseAddress> - <ConfigurationOverrideFile> - </ConfigurationOverrideFile> - <DefineConstants>DEBUG;TRACE;</DefineConstants> - <DocumentationFile> - </DocumentationFile> <DebugSymbols>true</DebugSymbols> - <FileAlignment>4096</FileAlignment> + <DebugType>full</DebugType> <Optimize>false</Optimize> - <OutputPath>..\Binaries\Debug\</OutputPath> - <RegisterForComInterop>False</RegisterForComInterop> - <RemoveIntegerChecks>False</RemoveIntegerChecks> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <DebugType>full</DebugType> - <Prefer32Bit>false</Prefer32Bit> + <RunCodeAnalysis>false</RunCodeAnalysis> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <BaseAddress>285212672</BaseAddress> - <ConfigurationOverrideFile> - </ConfigurationOverrideFile> - <DefineConstants>TRACE;</DefineConstants> - <DocumentationFile>AgateLib.xml</DocumentationFile> - <FileAlignment>4096</FileAlignment> + <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> - <OutputPath>..\Binaries\Release\</OutputPath> - <RegisterForComInterop>False</RegisterForComInterop> - <RemoveIntegerChecks>False</RemoveIntegerChecks> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <DebugType>none</DebugType> - <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <DebugSymbols>true</DebugSymbols> - <OutputPath>..\Binaries\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE;</DefineConstants> - <BaseAddress>285212672</BaseAddress> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <FileAlignment>4096</FileAlignment> - <PlatformTarget>x64</PlatformTarget> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> <DebugType>full</DebugType> - <WarningLevel>4</WarningLevel> - <Optimize>false</Optimize> - <Prefer32Bit>false</Prefer32Bit> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> - <OutputPath>bin\x64\Release\</OutputPath> - <DefineConstants>TRACE;</DefineConstants> - <BaseAddress>285212672</BaseAddress> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <DocumentationFile>AgateLib.xml</DocumentationFile> - <Optimize>true</Optimize> - <FileAlignment>4096</FileAlignment> - <PlatformTarget>x64</PlatformTarget> - <DebugType>none</DebugType> - <WarningLevel>4</WarningLevel> - <Prefer32Bit>false</Prefer32Bit> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <DebugSymbols>true</DebugSymbols> - <OutputPath>..\Binaries\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE;</DefineConstants> - <BaseAddress>285212672</BaseAddress> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <FileAlignment>4096</FileAlignment> <PlatformTarget>x86</PlatformTarget> - <DebugType>full</DebugType> - <WarningLevel>4</WarningLevel> - <Optimize>false</Optimize> - <UseVSHostingProcess>true</UseVSHostingProcess> - <Prefer32Bit>false</Prefer32Bit> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> - <OutputPath>..\Binaries\Release\</OutputPath> - <DefineConstants>TRACE;</DefineConstants> - <BaseAddress>285212672</BaseAddress> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <DocumentationFile>AgateLib.xml</DocumentationFile> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> <Optimize>true</Optimize> - <FileAlignment>4096</FileAlignment> + <DebugType>pdbonly</DebugType> <PlatformTarget>x86</PlatformTarget> - <DebugType>none</DebugType> - <WarningLevel>4</WarningLevel> - <Prefer32Bit>false</Prefer32Bit> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> <ItemGroup> - <Reference Include="System"> - <Name>System</Name> - </Reference> - <Reference Include="System.Core"> - <Name>System.Core</Name> - </Reference> - <Reference Include="System.Data" /> - <Reference Include="System.XML" /> - <Reference Include="System.Xml.Linq" /> + <!-- A reference to the entire .NET Framework is automatically included --> + <Folder Include="Serialization\Xle\" /> </ItemGroup> - <ItemGroup /> <ItemGroup> <Compile Include="AgateException.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="AgateFileProvider.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="AgateGame.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="AgateSetup.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="AppInitParameters.cs"> <SubType>Code</SubType> </Compile> @@ -150,21 +76,13 @@ <Compile Include="Core.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Data\AgateDatabaseException.cs" /> - <Compile Include="Data\AgateColumn.cs" /> - <Compile Include="Data\AgateDatabase.cs" /> - <Compile Include="Data\AgateRow.cs" /> - <Compile Include="Data\AgateTable.cs" /> - <Compile Include="Data\AgateColumnDictionary.cs" /> - <Compile Include="Data\AgateDataHelper.cs" /> - <Compile Include="Data\FieldType.cs" /> - <Compile Include="Data\AgateRowList.cs" /> - <Compile Include="Data\AgateTableDictionary.cs" /> <Compile Include="Diagnostics\AgateConsole.cs" /> <Compile Include="Diagnostics\ConsoleSupport\AgateConsoleCommandProcessor.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleDictionary.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessage.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessageType.cs" /> + <Compile Include="Diagnostics\ConsoleSupport\DescriptionAttribute.cs" /> + <Compile Include="Diagnostics\ConsoleSupport\ICommandProcessor.cs" /> <Compile Include="Diagnostics\Log.cs" /> <Compile Include="DisplayLib\FrameBuffer.cs" /> <Compile Include="DisplayLib\IFrameBuffer.cs" /> @@ -180,6 +98,9 @@ <Compile Include="DisplayLib\Shaders\Implementation\Lighting3DImpl.cs" /> <Compile Include="DisplayLib\Shaders\Lighting2D.cs" /> <Compile Include="DisplayLib\Shaders\Lighting3D.cs" /> + <Compile Include="Drivers\DriverImplBase.cs"> + <SubType>Code</SubType> + </Compile> <Compile Include="Drivers\IAgateFactory.cs" /> <Compile Include="Drivers\IAudioFactory.cs" /> <Compile Include="Drivers\IDisplayFactory.cs" /> @@ -189,7 +110,6 @@ <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> <Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" /> - <Compile Include="Diagnostics\ConsoleSupport\ICommandProcessor.cs" /> <Compile Include="IFileProvider.cs"> <SubType>Code</SubType> </Compile> @@ -204,20 +124,11 @@ <Compile Include="Platform\IStopWatch.cs" /> <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> - <Compile Include="Platform\Timing.cs" /> <Compile Include="Resources\ImageResource.cs" /> - <Compile Include="Serialization\Xle\CompressionType.cs" /> - <Compile Include="Serialization\Xle\IXleTypeSerializer.cs" /> - <Compile Include="Serialization\Xle\NumericEncoding.cs" /> - <Compile Include="Serialization\Xle\TypeSerializers\PointFSerializer.cs" /> - <Compile Include="Serialization\Xle\TypeSerializers\PointSerializer.cs" /> - <Compile Include="Serialization\Xle\TypeSerializers\RectangleFSerializer.cs" /> - <Compile Include="Serialization\Xle\TypeSerializers\RectangleSerializer.cs" /> - <Compile Include="Serialization\Xle\TypeSerializers\SizeFSerializer.cs" /> - <Compile Include="Serialization\Xle\TypeSerializers\SizeSerializer.cs" /> - <Compile Include="Serialization\Xle\XleTypeSerializerBase.cs" /> - <Compile Include="Serialization\Xle\XleTypeSerializerCollection.cs" /> <Compile Include="Settings\SettingsGroup.cs" /> + <Compile Include="Platform\Timing.cs"> + <SubType>Code</SubType> + </Compile> <Compile Include="AudioLib\Audio.cs"> <SubType>Code</SubType> </Compile> @@ -326,36 +237,12 @@ <Compile Include="DisplayLib\Shaders\Implementation\UniformState.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Drivers\AgateDriverInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\AgateDriverReporter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\AgateSandBoxLoader.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\DriverImplBase.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\IDesktopDriver.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\IUserSetSystems.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Drivers\NullInputImpl.cs"> <SubType>Code</SubType> </Compile> <Compile Include="Drivers\NullSoundImpl.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Drivers\Registrar.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\TypeID.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Geometry\Color.cs"> <SubType>Code</SubType> </Compile> @@ -467,15 +354,6 @@ <Compile Include="InputLib\Mouse.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="InternalResources\Data.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InternalResources\DataResources.Designer.cs"> - <DependentUpon>DataResources.resx</DependentUpon> - <SubType>Code</SubType> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - </Compile> <Compile Include="Meshes\Loaders\OBJFileRepresentation.cs"> <SubType>Code</SubType> </Compile> @@ -554,27 +432,6 @@ <Compile Include="Resources\XmlHelper.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Serialization\Formatters\Xml\XmlFormatter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Serialization\Xle\ITypeBinder.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Serialization\Xle\IXleSerializable.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Serialization\Xle\TypeBinder.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Serialization\Xle\XleSerializationException.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Serialization\Xle\XleSerializationInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Serialization\Xle\XleSerializer.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Sprites\FrameList.cs"> <SubType>Code</SubType> </Compile> @@ -606,32 +463,18 @@ <Compile Include="Utility\SurfacePacker.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Utility\TgzFileProvider.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Utility\ZipFileProvider.cs"> - <SubType>Code</SubType> - </Compile> - <EmbeddedResource Include="InternalResources\DataResources.resx"> - <SubType>Designer</SubType> - <Generator>ResXFileCodeGenerator</Generator> - <LastGenOutput>DataResources.Designer.cs</LastGenOutput> - </EmbeddedResource> <Compile Include="DisplayLib\Shaders\IShader2D.cs" /> <Compile Include="Settings\ISettingsTracer.cs" /> </ItemGroup> <ItemGroup> - <None Include="InternalResources\agate-black-gui.zip" /> - <None Include="InternalResources\Fonts.zip" /> - <None Include="InternalResources\images.tar.gz" /> <None Include="packages.config" /> </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <PropertyGroup> - <PreBuildEvent> - </PreBuildEvent> - <PostBuildEvent> - </PostBuildEvent> - </PropertyGroup> + <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> </Project> \ No newline at end of file Modified: trunk/AgateLib-Windows.sln =================================================================== --- trunk/AgateLib-Windows.sln 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib-Windows.sln 2014-07-25 01:57:36 UTC (rev 1415) @@ -10,17 +10,9 @@ EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{DC687DB2-90A8-484D-AB99-B3D29FDD8D44}" - ProjectSection(ProjectDependencies) = postProject - {9E095F03-BA3F-4EAD-A905-2A2647CE4405} = {9E095F03-BA3F-4EAD-A905-2A2647CE4405} - {00C7FA95-98F4-43D9-9B63-34122B1DB003} = {00C7FA95-98F4-43D9-9B63-34122B1DB003} - EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDL", "Drivers\AgateSDL\AgateSDL.csproj", "{00C7FA95-98F4-43D9-9B63-34122B1DB003}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib", "AgateLib\AgateLib.csproj", "{9490B719-829E-43A7-A5FE-8001F8A81759}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateOTK", "Drivers\AgateOTK\AgateOTK.csproj", "{9E095F03-BA3F-4EAD-A905-2A2647CE4405}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{F22ADCCC-7991-4F52-B2D0-697D60121BB3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{761301C3-2DC0-4F66-8B66-B16DF998F6C0}" @@ -32,8 +24,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "IntegrationTests\IntegrationTests.csproj", "{796D3B53-8828-475C-B5FF-5CA09F423C8A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib-Portable", "AgateLib\AgateLib-Portable.csproj", "{DB2152AD-E467-40A2-94E8-EB3804863C71}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.GL", "AgateLib.GL\AgateLib.GL.csproj", "{94734E5A-0344-43E8-BB30-E32E3F57F611}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.Platform.WindowsForms", "AgateLib.Platform.WindowsForms\AgateLib.Platform.WindowsForms.csproj", "{4B12561E-D37B-48A1-B6DB-218E94906C22}" @@ -59,17 +49,6 @@ {DC687DB2-90A8-484D-AB99-B3D29FDD8D44}.Release|Any CPU.Build.0 = Release|Any CPU {DC687DB2-90A8-484D-AB99-B3D29FDD8D44}.Release|x86.ActiveCfg = Release|x86 {DC687DB2-90A8-484D-AB99-B3D29FDD8D44}.Release|x86.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x86.ActiveCfg = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|x86.Build.0 = Debug|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|Any CPU.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|x86.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Public|x86.Build.0 = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.Build.0 = Release|Any CPU - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x86.ActiveCfg = Release|x86 - {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|x86.Build.0 = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.Build.0 = Debug|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|x86.ActiveCfg = Debug|x86 @@ -81,17 +60,6 @@ {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Any CPU.Build.0 = Release|Any CPU {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x86.ActiveCfg = Release|x86 {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|x86.Build.0 = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|x86.ActiveCfg = Debug|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|x86.Build.0 = Debug|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Public|Any CPU.ActiveCfg = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Public|x86.ActiveCfg = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Public|x86.Build.0 = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Any CPU.Build.0 = Release|Any CPU - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|x86.ActiveCfg = Release|x86 - {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|x86.Build.0 = Release|x86 {F22ADCCC-7991-4F52-B2D0-697D60121BB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F22ADCCC-7991-4F52-B2D0-697D60121BB3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F22ADCCC-7991-4F52-B2D0-697D60121BB3}.Debug|x86.ActiveCfg = Debug|x86 @@ -116,18 +84,6 @@ {796D3B53-8828-475C-B5FF-5CA09F423C8A}.Release|Any CPU.Build.0 = Release|Any CPU {796D3B53-8828-475C-B5FF-5CA09F423C8A}.Release|x86.ActiveCfg = Release|x86 {796D3B53-8828-475C-B5FF-5CA09F423C8A}.Release|x86.Build.0 = Release|x86 - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Debug|x86.ActiveCfg = Debug|x86 - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Debug|x86.Build.0 = Debug|x86 - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Public|Any CPU.ActiveCfg = Release|Any CPU - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Public|Any CPU.Build.0 = Release|Any CPU - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Public|x86.ActiveCfg = Release|x86 - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Public|x86.Build.0 = Release|x86 - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Release|Any CPU.Build.0 = Release|Any CPU - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Release|x86.ActiveCfg = Release|x86 - {DB2152AD-E467-40A2-94E8-EB3804863C71}.Release|x86.Build.0 = Release|x86 {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|Any CPU.Build.0 = Debug|Any CPU {94734E5A-0344-43E8-BB30-E32E3F57F611}.Debug|x86.ActiveCfg = Debug|x86 Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-25 01:57:36 UTC (rev 1415) @@ -105,15 +105,7 @@ <DesignTime>True</DesignTime> <AutoGen>True</AutoGen> </Compile> - <Compile Include="WinForms\SetSystemsForm.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="WinForms\SetSystemsForm.Designer.cs"> - <DependentUpon>SetSystemsForm.cs</DependentUpon> - </Compile> <Compile Include="WinForms\TypeConverters.cs" /> - <Compile Include="WinForms\WinFormsDriver.cs" /> - <Compile Include="WinForms\WinFormsReporter.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\AgateLib.GL\AgateLib.GL.csproj"> @@ -139,10 +131,6 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Icons.Designer.cs</LastGenOutput> </EmbeddedResource> - <EmbeddedResource Include="WinForms\SetSystemsForm.resx"> - <DependentUpon>SetSystemsForm.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> </ItemGroup> <ItemGroup> <None Include="packages.config" /> Deleted: trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.Designer.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.Designer.cs 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.Designer.cs 2014-07-25 01:57:36 UTC (rev 1415) @@ -1,183 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -namespace AgateLib.Platform.WindowsForms.WinForms -{ - /// <summary> - /// Form which allos the user to choose what drivers should be used. - /// </summary> - partial class SetSystemsForm - { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { - this.btnOK = new System.Windows.Forms.Button(); - this.btnCancel = new System.Windows.Forms.Button(); - this.displayList = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.inputList = new System.Windows.Forms.ComboBox(); - this.label3 = new System.Windows.Forms.Label(); - this.audioList = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // btnOK - // - this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnOK.Location = new System.Drawing.Point(190, 95); - this.btnOK.Name = "btnOK"; - this.btnOK.Size = new System.Drawing.Size(54, 23); - this.btnOK.TabIndex = 3; - this.btnOK.Text = "OK"; - this.btnOK.UseVisualStyleBackColor = true; - this.btnOK.Click += new System.EventHandler(this.btnOK_Click); - // - // btnCancel - // - this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(250, 95); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(54, 23); - this.btnCancel.TabIndex = 7; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - // - // displayList - // - this.displayList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.displayList.DisplayMember = "FriendlyName"; - this.displayList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.displayList.FormattingEnabled = true; - this.displayList.Location = new System.Drawing.Point(76, 12); - this.displayList.Name = "displayList"; - this.displayList.Size = new System.Drawing.Size(228, 21); - this.displayList.TabIndex = 8; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(12, 15); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(58, 27); - this.label1.TabIndex = 9; - this.label1.Text = "Display"; - this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(12, 69); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(58, 30); - this.label2.TabIndex = 11; - this.label2.Text = "Input"; - this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // inputList - // - this.inputList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.inputList.DisplayMember = "FriendlyName"; - this.inputList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.inputList.FormattingEnabled = true; - this.inputList.Location = new System.Drawing.Point(76, 66); - this.inputList.Name = "inputList"; - this.inputList.Size = new System.Drawing.Size(228, 21); - this.inputList.TabIndex = 10; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(12, 42); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(58, 27); - this.label3.TabIndex = 13; - this.label3.Text = "Audio"; - this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // audioList - // - this.audioList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioList.DisplayMember = "FriendlyName"; - this.audioList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.audioList.FormattingEnabled = true; - this.audioList.Location = new System.Drawing.Point(76, 39); - this.audioList.Name = "audioList"; - this.audioList.Size = new System.Drawing.Size(228, 21); - this.audioList.TabIndex = 12; - // - // SetSystemsForm - // - this.AcceptButton = this.btnOK; - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; - this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(316, 130); - this.Controls.Add(this.inputList); - this.Controls.Add(this.audioList); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.label3); - this.Controls.Add(this.btnOK); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.displayList); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "SetSystemsForm"; - this.Text = "Select Drivers"; - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button btnOK; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.ComboBox displayList; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.ComboBox inputList; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.ComboBox audioList; - - } -} - Deleted: trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.cs 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.cs 2014-07-25 01:57:36 UTC (rev 1415) @@ -1,195 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; -using System.Windows.Forms; - -using AgateLib.Drivers; - -namespace AgateLib.Platform.WindowsForms.WinForms -{ - /// <summary> - /// A form which is used to ask the user which subsystems to use. - /// </summary> - /// <remarks> - /// [Experimental - This class will be moved to into a different assembly - /// in the future.] - /// </remarks> - partial class SetSystemsForm : Form, IUserSetSystems - { - private bool mChooseDisplay, mChooseAudio, mChooseInput; - private DisplayTypeID mDisplayType; - private AudioTypeID mAudioType; - private InputTypeID mInputType; - - /// <summary> - /// DisplayTypeID chosen by user. - /// </summary> - public DisplayTypeID DisplayType - { - get { return mDisplayType; } - } - /// <summary> - /// AudioTypeID chosen by user. - /// </summary> - public AudioTypeID AudioType - { - get { return mAudioType; } - } - /// <summary> - /// InputTypeID chosen by user. - /// </summary> - public InputTypeID InputType - { - get { return mInputType; } - } - - /// <summary> - /// Constructs a SetSystemsForm object. - /// </summary> - public SetSystemsForm() - { - InitializeComponent(); - - Icon = FormUtil.AgateLibIcon; - } - - /// <summary> - /// Adds. - /// </summary> - /// <param name="info"></param> - public void AddDisplayType(AgateDriverInfo info) - { - displayList.Items.Add(info); - } - /// <summary> - /// Adds. - /// </summary> - /// <param name="info"></param> - public void AddAudioType(AgateDriverInfo info) - { - audioList.Items.Add(info); - } - /// <summary> - /// Adds. - /// </summary> - /// <param name="info"></param> - public void AddInputType(AgateDriverInfo info) - { - inputList.Items.Add(info); - } - - private void btnOK_Click(object sender, EventArgs e) - { - if (mChooseDisplay) - { - AgateDriverInfo display = (AgateDriverInfo)displayList.SelectedItem; - mDisplayType = (DisplayTypeID)display.DriverTypeID; - } - - if (mChooseAudio) - { - AgateDriverInfo audio = (AgateDriverInfo)audioList.SelectedItem; - mAudioType = (AudioTypeID)audio.DriverTypeID; - } - - if (mChooseInput) - { - AgateDriverInfo input = (AgateDriverInfo)inputList.SelectedItem; - mInputType = (InputTypeID)input.DriverTypeID; - } - } - - private void SelectFirst(ComboBox theComboBox) - { - if (theComboBox.Items.Count > 0) - theComboBox.SelectedIndex = 0; - } - - private void SelectItem(ComboBox theComboBox, int driverTypeID) - { - for (int i = 0; i < theComboBox.Items.Count; i++) - { - AgateDriverInfo item = (AgateDriverInfo)theComboBox.Items[i]; - - if (item.DriverTypeID == driverTypeID) - { - theComboBox.SelectedIndex = i; - return; - } - } - - SelectFirst(theComboBox); - } - - #region IUserSetSystems Members - - public void SetChoices(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput) - { - mChooseDisplay = chooseDisplay; - mChooseAudio = chooseAudio; - mChooseInput = chooseInput; - - displayList.Enabled = mChooseDisplay; - audioList.Enabled = mChooseAudio; - inputList.Enabled = mChooseInput; - - if (preferredDisplay != DisplayTypeID.AutoSelect) - SelectItem(displayList, (int)preferredDisplay); - else - SelectFirst(displayList); - - if (preferredAudio != AudioTypeID.AutoSelect) - SelectItem(audioList, (int)preferredAudio); - else - SelectFirst(audioList); - - if (preferredInput != InputTypeID.AutoSelect) - SelectItem(inputList, (int)preferredInput); - else - SelectFirst(inputList); - } - - - - public SetSystemsDialogResult RunDialog() - { - if (displayList.Items.Count == 0 && mChooseDisplay) - throw new AgateException("No display drivers were found."); - - DialogResult res = ShowDialog(); - - switch (res) - { - case DialogResult.OK: - return SetSystemsDialogResult.OK; - - case DialogResult.Cancel: - default: - return SetSystemsDialogResult.Cancel; - } - } - - #endregion - } - -} \ No newline at end of file Deleted: trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.resx =================================================================== --- trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.resx 2014-07-25 01:53:37 UTC (rev 1414) +++ trunk/AgateLib.Platform.WindowsForms/WinForms/SetSystemsForm.resx 2014-07-25 01:57:36 UTC (rev 1415) @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> - <!-- - Microsoft ResX Schema - - Version 2.0 - - The primary goals of this format is to allow a simple XML format - that is mostly human readable. The generation and parsing of the - various data types are done through the TypeConverter classes - associated with the data types. - - Example: - - ... ado.net/XML headers & schema ... - <resheader name="resmimetype">text/microsoft-resx</resheader> - <resheader name="version">2.0</resheader> - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> - <value>[base64 mime encoded serialized .NET Framework object]</value> - </data> - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> - <comment>This is a comment</comment> - </data> - - There are any number of "resheader" rows that contain simple - name/value pairs. - - Each data row contains a name, and value. The row also contains a - type or mimetype. Type corresponds to a .NET class that support - text/value conversion through the TypeConverter architecture. - Classes that don't support this are serialized and stored with the - mimetype set. - - The mimetype is used for serialized objects, and tells the - ResXResourceReader how to depersist the object. This is currently not - extensible. For a given mimetype the value must be set accordingly: - - Note - application/x-microsoft.net.object.binary.base64 is the format - that the ResXResourceWriter will generate, however the reader can - read any of the formats listed below. - - mimetype: application/x-microsoft.net.object.binary.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.soap.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.bytearray.base64 - value : The object must be serialized into a byte array - : using a System.ComponentModel.TypeConverter - : and then encoded with base64 encoding. - --> - <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> - <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> - <xsd:element name="root" msdata:IsDataSet="true"> - <xsd:complexType> - <xsd:choice maxOccurs="unbounded"> - <xsd:element name="metadata"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" /> - </xsd:sequence> - <xsd:attribute name="name" use="required" type="xsd:string" /> ... [truncated message content] |
From: <ka...@us...> - 2014-07-25 01:53:42
|
Revision: 1414 http://sourceforge.net/p/agate/code/1414 Author: kanato Date: 2014-07-25 01:53:37 +0000 (Fri, 25 Jul 2014) Log Message: ----------- Even cleaner Modified Paths: -------------- trunk/AgateLib/AgateGame.cs trunk/AgateLib/AgateLib-Portable.csproj trunk/AgateLib/AgateLib.csproj trunk/AgateLib/AudioLib/Music.cs trunk/AgateLib/AudioLib/SoundBuffer.cs trunk/AgateLib/BitmapFont/BitmapFontImpl.cs trunk/AgateLib/Core.cs trunk/AgateLib/Diagnostics/AgateConsole.cs trunk/AgateLib/Diagnostics/ConsoleSupport/AgateConsoleCommandProcessor.cs trunk/AgateLib/DisplayLib/FontSurface.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs trunk/AgateLib/DisplayLib/PixelBuffer.cs trunk/AgateLib/DisplayLib/Surface.cs trunk/AgateLib/DisplayLib/TextLayout.cs trunk/AgateLib/Drivers/DriverImplBase.cs trunk/AgateLib/Geometry/Rectangle.cs trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureColorNormal.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormalTangent.cs trunk/AgateLib/IO/FileSystem.cs trunk/AgateLib/Platform/Timing.cs trunk/AgateLib/Resources/AgateResourceCollection.cs trunk/AgateLib/Resources/AgateResourceLoader.cs trunk/AgateLib/Resources/ImageResource.cs trunk/AgateLib/Resources/SpriteResource.cs trunk/AgateLib/Settings/PersistantSettings.cs trunk/AgateLib/Utility/FileProviderList.cs trunk/AgateLib/Utility/FileSystemProvider.cs trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_Surface.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs Added Paths: ----------- trunk/AgateLib/Diagnostics/ConsoleSupport/DescriptionAttribute.cs trunk/AgateLib/IO/IDirectory.cs trunk/AgateLib/IO/IFile.cs trunk/AgateLib/IO/IPath.cs Modified: trunk/AgateLib/AgateGame.cs =================================================================== --- trunk/AgateLib/AgateGame.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/AgateGame.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -85,49 +85,38 @@ /// <returns></returns> public int Run(string[] args) { - using (AgateSetup setup = new AgateSetup(args)) - { - setup.Initialize( - InitParams.InitializeDisplay, - InitParams.InitializeAudio, - InitParams.InitializeJoysticks); + CreateDisplayWindow(); - if (setup.WasCanceled) - return 1; + mFont = new FontSurface("Arial", 14); - CreateDisplayWindow(); + if (InitParams.ShowSplashScreen) + { + DoSplash(); + } - mFont = FontSurface.AgateSans14; + Initialize(); - if (InitParams.ShowSplashScreen) - { - DoSplash(); - } + while (MainWindow.IsClosed == false) + { + Update(Display.DeltaTime); - Initialize(); + if (MainWindow.IsClosed) + break; - while (MainWindow.IsClosed == false) - { - Update(Display.DeltaTime); + // if (GuiRoot != null) + // GuiRoot.DoUpdate(); - if (MainWindow.IsClosed) - break; -// if (GuiRoot != null) -// GuiRoot.DoUpdate(); - + Display.RenderTarget = MainWindow.FrameBuffer; + Display.BeginFrame(); - Display.RenderTarget = MainWindow.FrameBuffer; - Display.BeginFrame(); + Render(); - Render(); + // if (GuiRoot != null) + // GuiRoot.Draw(); -// if (GuiRoot != null) -// GuiRoot.Draw(); - - Display.EndFrame(); - Core.KeepAlive(); - } + Display.EndFrame(); + Core.KeepAlive(); } return 0; @@ -203,8 +192,8 @@ if (mSplashFadeDone) { - Surface powered = InternalResources.Data.PoweredBy; - Size size = powered.SurfaceSize; + Surface powered = null;// InternalResources.Data.PoweredBy; + Size size = Size.Empty;// powered.SurfaceSize; int bottom = MainWindow.Height - size.Height; int h = mFont.FontHeight; @@ -232,8 +221,6 @@ Display.EndFrame(); Core.KeepAlive(); - System.Threading.Thread.Sleep(0); - if (MainWindow.IsClosed) return; } @@ -262,8 +249,8 @@ { Display.Clear(Color.White); - Surface powered = InternalResources.Data.PoweredBy; - Size size = powered.SurfaceSize; + Surface powered = null;//= InternalResources.Data.PoweredBy; + Size size = Size.Empty;// powered.SurfaceSize; int left = (int)(mTotalSplashTime * size.Width - size.Width) + 1; Rectangle gradientRect = new Rectangle(left, MainWindow.Height - size.Height, @@ -274,8 +261,11 @@ else if (left > size.Width) mSplashFadeDone = true; - powered.DisplayAlignment = OriginAlignment.BottomLeft; - powered.Draw(0, MainWindow.Height); + if (powered != null) + { + powered.DisplayAlignment = OriginAlignment.BottomLeft; + powered.Draw(0, MainWindow.Height); + } Gradient g = new Gradient( Color.FromArgb(0, Color.White), @@ -339,26 +329,26 @@ get { return mWindow; } } -// / <summary> -// / Gets or sets the GuiRoot object. -// / </summary> -// public Gui.GuiRoot GuiRoot -// { -// get { return mGui; } -// set -// { -// if (value == null && mGui == null) -// return; -// -// if (mGui != null) -// mGui.EnableInteraction = false; -// -// mGui = value; -// -// if (mGui != null) -// mGui.EnableInteraction = true; -// } -// } + // / <summary> + // / Gets or sets the GuiRoot object. + // / </summary> + // public Gui.GuiRoot GuiRoot + // { + // get { return mGui; } + // set + // { + // if (value == null && mGui == null) + // return; + // + // if (mGui != null) + // mGui.EnableInteraction = false; + // + // mGui = value; + // + // if (mGui != null) + // mGui.EnableInteraction = true; + // } + // } #endregion Modified: trunk/AgateLib/AgateLib-Portable.csproj =================================================================== --- trunk/AgateLib/AgateLib-Portable.csproj 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/AgateLib-Portable.csproj 2014-07-25 01:53:37 UTC (rev 1414) @@ -60,9 +60,6 @@ <Compile Include="AgateException.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="AgateFileProvider.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="AgateGame.cs"> <SubType>Code</SubType> </Compile> @@ -84,6 +81,7 @@ <Compile Include="Diagnostics\ConsoleSupport\ConsoleDictionary.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessage.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessageType.cs" /> + <Compile Include="Diagnostics\ConsoleSupport\DescriptionAttribute.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ICommandProcessor.cs" /> <Compile Include="Diagnostics\Log.cs" /> <Compile Include="DisplayLib\FrameBuffer.cs" /> @@ -120,6 +118,9 @@ <Compile Include="InputLib\HatState.cs" /> <Compile Include="InputLib\JoystickEventArgs.cs" /> <Compile Include="IO\FileSystem.cs" /> + <Compile Include="IO\IDirectory.cs" /> + <Compile Include="IO\IFile.cs" /> + <Compile Include="IO\IPath.cs" /> <Compile Include="Platform\IStopWatch.cs" /> <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> @@ -353,12 +354,6 @@ <Compile Include="InputLib\Mouse.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="InternalResources\DataResources.Designer.cs"> - <DependentUpon>DataResources.resx</DependentUpon> - <SubType>Code</SubType> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - </Compile> <Compile Include="Meshes\Loaders\OBJFileRepresentation.cs"> <SubType>Code</SubType> </Compile> @@ -468,18 +463,10 @@ <Compile Include="Utility\SurfacePacker.cs"> <SubType>Code</SubType> </Compile> - <EmbeddedResource Include="InternalResources\DataResources.resx"> - <SubType>Designer</SubType> - <Generator>ResXFileCodeGenerator</Generator> - <LastGenOutput>DataResources.Designer.cs</LastGenOutput> - </EmbeddedResource> <Compile Include="DisplayLib\Shaders\IShader2D.cs" /> <Compile Include="Settings\ISettingsTracer.cs" /> </ItemGroup> <ItemGroup> - <None Include="InternalResources\agate-black-gui.zip" /> - <None Include="InternalResources\Fonts.zip" /> - <None Include="InternalResources\images.tar.gz" /> <None Include="packages.config" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/AgateLib.csproj 2014-07-25 01:53:37 UTC (rev 1414) @@ -198,6 +198,9 @@ <Compile Include="InputLib\HatState.cs" /> <Compile Include="InputLib\JoystickEventArgs.cs" /> <Compile Include="IO\FileSystem.cs" /> + <Compile Include="IO\IDirectory.cs" /> + <Compile Include="IO\IFile.cs" /> + <Compile Include="IO\IPath.cs" /> <Compile Include="Platform\IStopWatch.cs" /> <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> Modified: trunk/AgateLib/AudioLib/Music.cs =================================================================== --- trunk/AgateLib/AudioLib/Music.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/AudioLib/Music.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -23,6 +23,7 @@ using AgateLib.Drivers; using AgateLib.AudioLib.ImplementationBase; using AgateLib.Utility; +using AgateLib.IO; namespace AgateLib.AudioLib { @@ -45,17 +46,8 @@ /// </summary> /// <param name="filename">The name of the file to load.</param> public Music(string filename) - : this(AgateFileProvider.Music, filename) - { } - /// <summary> - /// Constructs a Music object from a file given by the specified IFileProvider. - /// </summary> - /// <param name="fileProvider"></param> - /// <param name="filename"></param> - public Music(IFileProvider fileProvider, string filename) - : this() { - using (System.IO.Stream s = fileProvider.OpenRead(filename)) + using (System.IO.Stream s = FileSystem.OpenRead(filename)) { impl = Audio.Impl.CreateMusic(s); } Modified: trunk/AgateLib/AudioLib/SoundBuffer.cs =================================================================== --- trunk/AgateLib/AudioLib/SoundBuffer.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/AudioLib/SoundBuffer.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -64,27 +64,8 @@ /// </summary> /// <param name="filename"></param> public SoundBuffer(string filename) - : this(AgateFileProvider.Sounds, filename) - { } - /// <summary> - /// Constructs a SoundBuffer object, loading audio data from the - /// specified file given the specified IFileProvider. - /// </summary> - /// <param name="fileProvider"></param> - /// <param name="filename"></param> - public SoundBuffer(IFileProvider fileProvider, string filename) { - if (fileProvider.IsRealFile(filename)) - { - mImpl = Audio.Impl.CreateSoundBuffer(fileProvider.ResolveFile(filename)); - } - else - { - using (System.IO.Stream s = fileProvider.OpenRead(filename)) - { - mImpl = Audio.Impl.CreateSoundBuffer(s); - } - } + mImpl = Audio.Impl.CreateSoundBuffer(filename); mFilename = filename; } Modified: trunk/AgateLib/BitmapFont/BitmapFontImpl.cs =================================================================== --- trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -26,6 +26,7 @@ using AgateLib.Geometry; using AgateLib.Resources; using AgateLib.DisplayLib.Cache; +using AgateLib.IO; namespace AgateLib.BitmapFont { @@ -86,7 +87,7 @@ /// <param name="characterSize">Size of each character in the image.</param> public BitmapFontImpl(string filename, Size characterSize) { - FontName = System.IO.Path.GetFileNameWithoutExtension(filename); + FontName = FileSystem.Path.GetFileNameWithoutExtension(filename); mFontMetrics = new FontMetrics(); mSurface = new Surface(filename); Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Core.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,6 +27,8 @@ using AgateLib.Settings; using AgateLib.Platform; using AgateLib.Drivers; +using AgateLib.Diagnostics; +using AgateLib.IO; namespace AgateLib { @@ -221,10 +223,10 @@ string text = b.ToString(); // show the error dialog if AgateWinForms.dll is present. - if (showDialog && Drivers.Registrar.WinForms != null) - { - Drivers.Registrar.WinForms.ShowErrorDialog(message, e, level); - } + //if (showDialog && Drivers.Registrar.WinForms != null) + //{ + // Drivers.Registrar.WinForms.ShowErrorDialog(message, e, level); + //} using (StreamWriter filewriter = OpenErrorFile()) { @@ -232,7 +234,7 @@ filewriter.Write(text); } - Trace.WriteLine(text); + Log.WriteLine(text); } /// <summary> @@ -259,13 +261,13 @@ { if (sWroteHeader == true) { - FileStream stream = File.Open(ErrorFile, FileMode.Append, FileAccess.Write); + Stream stream = FileSystem.OpenWrite(ErrorFile, true); return new StreamWriter(stream); } else { - FileStream stream = File.Open(ErrorFile, FileMode.Create, FileAccess.Write); + var stream = FileSystem.OpenWrite(ErrorFile); StreamWriter writer = new StreamWriter(stream); WriteHeader(writer); @@ -281,8 +283,7 @@ "Error message: " + e.Message + "\r\n" + "Errors cannot be saved to a text file."; - Debug.WriteLine(message); - Trace.WriteLine(message); + Log.WriteLine(message); return null; } @@ -410,7 +411,7 @@ while (IsActive == false && AutoPause) { - System.Threading.Thread.Sleep(25); + //System.Threading.Thread.Sleep(25); Display.ProcessEvents(); // Update Audio Engine, if necessary @@ -433,16 +434,6 @@ InputLib.JoystickInput.PollTimer(); } - /// <summary> - /// Returns the directory the application that was started resides in. - /// </summary> - public static string BaseDirectory - { - get - { - return System.AppDomain.CurrentDomain.BaseDirectory; - } - } /// <summary> /// returns time since agatelib was initialized in milliseconds. @@ -450,7 +441,7 @@ /// <returns></returns> internal static double GetTime() { - return mTime.ElapsedTicks / (double)System.Diagnostics.Stopwatch.Frequency * 1000.0; + return mTime.TotalSeconds; } Modified: trunk/AgateLib/Diagnostics/AgateConsole.cs =================================================================== --- trunk/AgateLib/Diagnostics/AgateConsole.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Diagnostics/AgateConsole.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -74,7 +74,7 @@ if (sInstance == null) return; if (Font == null) - Font = FontSurface.AgateSans10; + Font = new FontSurface("Arial", 10); sInstance.DrawImpl(); } Modified: trunk/AgateLib/Diagnostics/ConsoleSupport/AgateConsoleCommandProcessor.cs =================================================================== --- trunk/AgateLib/Diagnostics/ConsoleSupport/AgateConsoleCommandProcessor.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Diagnostics/ConsoleSupport/AgateConsoleCommandProcessor.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -43,7 +43,7 @@ { try { - args[i] = Convert.ChangeType(tokens[i + 1], parameters[i].ParameterType); + args[i] = Convert.ChangeType(tokens[i + 1], parameters[i].ParameterType, System.Globalization.CultureInfo.InvariantCulture); } catch { Added: trunk/AgateLib/Diagnostics/ConsoleSupport/DescriptionAttribute.cs =================================================================== --- trunk/AgateLib/Diagnostics/ConsoleSupport/DescriptionAttribute.cs (rev 0) +++ trunk/AgateLib/Diagnostics/ConsoleSupport/DescriptionAttribute.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.Diagnostics.ConsoleSupport +{ + public class DescriptionAttribute : Attribute + { + public string Description { get; set; } + } +} Modified: trunk/AgateLib/DisplayLib/FontSurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontSurface.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/DisplayLib/FontSurface.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -121,7 +121,7 @@ if (res is BitmapFontResource) { - Surface surf = new Surface(resources.FileProvider, resources.FullFileName(bmpFont.Image)); + Surface surf = new Surface(resources.FullFileName(bmpFont.Image)); mImpl = new BitmapFontImpl(surf, bmpFont.FontMetrics, resourceName); } @@ -670,7 +670,7 @@ return obj.ToString(); } - + /* #region --- Built-in Fonts --- /// <summary> @@ -741,8 +741,8 @@ #endregion + */ - } /// <summary> Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -266,9 +266,7 @@ // hack to make sure delta time is never zero. if (mDeltaTime == 0.0) { - System.Threading.Thread.Sleep(1); - CalcDeltaTime(); - return; + mDeltaTime += 0.0000001; } } else Modified: trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -194,7 +194,7 @@ #endregion #region --- Protected Methods --- - + /// <summary> /// Scans a memory area to see if it entirely contains pixels which won't be /// seen when drawn. @@ -209,31 +209,12 @@ /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param> /// <returns></returns> [CLSCompliant(false)] - protected bool IsRowBlankScanARGB(IntPtr pixelData, int row, int cols, int strideInBytes, + protected virtual bool IsRowBlankScanARGB(IntPtr pixelData, int row, int cols, int strideInBytes, int alphaThreshold, uint alphaMask, int alphaShift) { - unsafe - { - uint* ptr = (uint*)pixelData; + throw new NotImplementedException(); + } - int start = row * strideInBytes / sizeof(uint); - - for (int i = 0; i < cols; i++) - { - int index = start + i; - uint pixel = ptr[index]; - byte alpha = (byte)((pixel & alphaMask) >> alphaShift); - - if (alpha > alphaThreshold) - { - return false; - } - - } - } - - return true; - } /// <summary> /// Scans a memory area to see if it entirely contains pixels which won't be /// seen when drawn. @@ -248,31 +229,12 @@ /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param> /// <returns></returns> [CLSCompliant(false)] - protected bool IsColBlankScanARGB(IntPtr pixelData, int col, int rows, int strideInBytes, + protected virtual bool IsColBlankScanARGB(IntPtr pixelData, int col, int rows, int strideInBytes, int alphaThreshold, uint alphaMask, int alphaShift) { - unsafe - { - uint* ptr = (uint*)pixelData; + throw new NotImplementedException(); + } - - for (int i = 0; i < rows; i++) - { - int index = col + i * strideInBytes / sizeof(uint); - uint pixel = ptr[index]; - byte alpha = (byte)((pixel & alphaMask) >> alphaShift); - - if (alpha > alphaThreshold) - { - return false; - } - - } - } - - return true; - - } #endregion }; } Modified: trunk/AgateLib/DisplayLib/PixelBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/PixelBuffer.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/DisplayLib/PixelBuffer.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -712,78 +712,80 @@ /// <param name="srcRowStride"></param> public void SetData(IntPtr data, PixelFormat srcFormat, int srcRowStride) { - int sourceStride = GetPixelStride(srcFormat); + throw new NotImplementedException(); - unsafe - { - if (srcFormat == this.PixelFormat) - { - // optimized copy for same type of data - int startIndex = 0; - int rowLength = sourceStride * Width; + //int sourceStride = GetPixelStride(srcFormat); - IntPtr rowPtr = data; - byte* dataPtr = (byte*)data; + //unsafe + //{ + // if (srcFormat == this.PixelFormat) + // { + // // optimized copy for same type of data + // int startIndex = 0; + // int rowLength = sourceStride * Width; - for (int y = 0; y < Height; y++) - { - Marshal.Copy(rowPtr, mData, startIndex, rowLength); + // IntPtr rowPtr = data; + // byte* dataPtr = (byte*)data; - startIndex += RowStride; - dataPtr += srcRowStride; - rowPtr = (IntPtr)dataPtr; - } - } - else - { - byte[] srcPixel = new byte[srcRowStride]; - int destIndex = 0; - IntPtr rowPtr = data; - byte* dataPtr = (byte*)data; - int width = Width; - int destPixelStride = PixelStride; + // for (int y = 0; y < Height; y++) + // { + // Marshal.Copy(rowPtr, mData, startIndex, rowLength); - for (int y = 0; y < Height; y++) - { - Marshal.Copy(rowPtr, srcPixel, 0, srcRowStride); + // startIndex += RowStride; + // dataPtr += srcRowStride; + // rowPtr = (IntPtr)dataPtr; + // } + // } + // else + // { + // byte[] srcPixel = new byte[srcRowStride]; + // int destIndex = 0; + // IntPtr rowPtr = data; + // byte* dataPtr = (byte*)data; + // int width = Width; + // int destPixelStride = PixelStride; - // check for common Win32 - OpenGL conversion case - if (this.PixelFormat == PixelFormat.RGBA8888 && - srcFormat == PixelFormat.BGRA8888) - { - // this setup here is OPTIMIZED. - // Calling ConvertPixel for each pixel when loading a large - // image adds about 35% more CPU time to do the conversion. - // By eliminating the function call and processing this special - // case here we save some time on image loading. - int srcIndex = 0; + // for (int y = 0; y < Height; y++) + // { + // Marshal.Copy(rowPtr, srcPixel, 0, srcRowStride); - for (int x = 0; x < width; x++) - { - mData[destIndex] = srcPixel[srcIndex + 2]; - mData[destIndex + 1] = srcPixel[srcIndex + 1]; - mData[destIndex + 2] = srcPixel[srcIndex]; - mData[destIndex + 3] = srcPixel[srcIndex + 3]; + // // check for common Win32 - OpenGL conversion case + // if (this.PixelFormat == PixelFormat.RGBA8888 && + // srcFormat == PixelFormat.BGRA8888) + // { + // // this setup here is OPTIMIZED. + // // Calling ConvertPixel for each pixel when loading a large + // // image adds about 35% more CPU time to do the conversion. + // // By eliminating the function call and processing this special + // // case here we save some time on image loading. + // int srcIndex = 0; - destIndex += destPixelStride; - srcIndex += sourceStride; - } - } - else - { - for (int x = 0; x < width; x++) - { - ConvertPixel(mData, destIndex, this.PixelFormat, srcPixel, x * sourceStride, srcFormat); + // for (int x = 0; x < width; x++) + // { + // mData[destIndex] = srcPixel[srcIndex + 2]; + // mData[destIndex + 1] = srcPixel[srcIndex + 1]; + // mData[destIndex + 2] = srcPixel[srcIndex]; + // mData[destIndex + 3] = srcPixel[srcIndex + 3]; - destIndex += destPixelStride; - } - } + // destIndex += destPixelStride; + // srcIndex += sourceStride; + // } + // } + // else + // { + // for (int x = 0; x < width; x++) + // { + // ConvertPixel(mData, destIndex, this.PixelFormat, srcPixel, x * sourceStride, srcFormat); - dataPtr += srcRowStride; - rowPtr = (IntPtr)dataPtr; - } - } - } + // destIndex += destPixelStride; + // } + // } + + // dataPtr += srcRowStride; + // rowPtr = (IntPtr)dataPtr; + // } + // } + //} } Modified: trunk/AgateLib/DisplayLib/Surface.cs =================================================================== --- trunk/AgateLib/DisplayLib/Surface.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/DisplayLib/Surface.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -23,6 +23,7 @@ using AgateLib.Geometry; using AgateLib.DisplayLib.ImplementationBase; using AgateLib.Utility; +using AgateLib.IO; namespace AgateLib.DisplayLib { @@ -83,22 +84,13 @@ /// </summary> /// <param name="filename">Path and file name for the image file to load.</param> public Surface(string filename) - : this(AgateFileProvider.Images, filename) { - } - /// <summary> - /// Creates a surface object using the specified file provider to open the image file. - /// </summary> - /// <param name="filename">Path and file name for the image file to load.</param> - /// <param name="fileProvider">The IFileProvider object which will resolve the filename and open the stream</param> - public Surface(IFileProvider fileProvider, string filename) - { if (Display.Impl == null) throw new AgateException("AgateLib's display system has not been initialized."); if (string.IsNullOrEmpty(filename)) throw new ArgumentNullException("You must supply a file name."); - using (System.IO.Stream s = fileProvider.OpenRead(filename)) + using (System.IO.Stream s = FileSystem.OpenRead(filename)) { mImpl = Display.Impl.CreateSurface(s); } @@ -840,7 +832,7 @@ /// <returns></returns> public static ImageFileFormat FormatFromExtension(string filename) { - string ext = System.IO.Path.GetExtension(filename); + string ext = FileSystem.Path.GetExtension(filename); switch (ext) { Modified: trunk/AgateLib/DisplayLib/TextLayout.cs =================================================================== --- trunk/AgateLib/DisplayLib/TextLayout.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/DisplayLib/TextLayout.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -35,7 +35,8 @@ /// </summary> public void DrawAll() { - ForEach(x => x.Draw()); + foreach (var x in this) + x.Draw(); } /// <summary> Modified: trunk/AgateLib/Drivers/DriverImplBase.cs =================================================================== --- trunk/AgateLib/Drivers/DriverImplBase.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Drivers/DriverImplBase.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -1,3 +1,4 @@ +using AgateLib.Diagnostics; // The contents of this file are subject to the Mozilla Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at @@ -43,8 +44,7 @@ /// <param name="text"></param> protected void Report(string text) { - //Console.WriteLine(text); - System.Diagnostics.Trace.WriteLine(text); + Log.WriteLine(text); } } } Modified: trunk/AgateLib/Geometry/Rectangle.cs =================================================================== --- trunk/AgateLib/Geometry/Rectangle.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/Rectangle.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -105,7 +105,7 @@ } private static int ParseNumeric(string text) { - int equals = text.IndexOf("=", StringComparison.InvariantCultureIgnoreCase); + int equals = text.IndexOf("=", StringComparison.OrdinalIgnoreCase); int value = int.Parse(text.Substring(equals + 1), System.Globalization.CultureInfo.CurrentCulture); return value; } Modified: trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs =================================================================== --- trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,7 +27,7 @@ /// <summary> /// Vertex layout which only contains position and color information. /// </summary> - [StructLayout(LayoutKind.Sequential, Pack = 1)] + [StructLayout(LayoutKind.Sequential)] public struct PositionColor { /// <summary> Modified: trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs =================================================================== --- trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,7 +27,7 @@ /// <summary> /// Vertex structure with position, texture and color values /// </summary> - [StructLayout(LayoutKind.Sequential, Pack = 1)] + [StructLayout(LayoutKind.Sequential)] public struct PositionTextureColor { /// <summary> Modified: trunk/AgateLib/Geometry/VertexTypes/PositionTextureColorNormal.cs =================================================================== --- trunk/AgateLib/Geometry/VertexTypes/PositionTextureColorNormal.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/VertexTypes/PositionTextureColorNormal.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,7 +27,7 @@ /// <summary> /// Vertex structure with position, texture and normal values. /// </summary> - [StructLayout(LayoutKind.Sequential, Pack = 1)] + [StructLayout(LayoutKind.Sequential)] public struct PositionTextureColorNormal { /// <summary> Modified: trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs =================================================================== --- trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,7 +27,7 @@ /// <summary> /// Vertex structure with position, texture coordinates, normal, tangent, bitangent. /// </summary> - [StructLayout(LayoutKind.Sequential, Pack = 1)] + [StructLayout(LayoutKind.Sequential)] public struct PositionTextureNTB { /// <summary> Modified: trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs =================================================================== --- trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,7 +27,7 @@ /// <summary> /// Vertex structure with position, texture and normal values. /// </summary> - [StructLayout(LayoutKind.Sequential, Pack = 1)] + [StructLayout(LayoutKind.Sequential)] public struct PositionTextureNormal { /// <summary> Modified: trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormalTangent.cs =================================================================== --- trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormalTangent.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormalTangent.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -27,7 +27,7 @@ /// <summary> /// Vertex structure with position, texture coordinates, normal and tangent. /// </summary> - [StructLayout(LayoutKind.Sequential, Pack = 1)] + [StructLayout(LayoutKind.Sequential)] public struct PositionTextureNormalTangent { /// <summary> Modified: trunk/AgateLib/IO/FileSystem.cs =================================================================== --- trunk/AgateLib/IO/FileSystem.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/IO/FileSystem.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -12,5 +12,15 @@ { throw new NotImplementedException(); } + public static Stream OpenWrite(string ErrorFile, bool append = false) + { + throw new NotImplementedException(); + } + + + public static IFile File { get; set; } + public static IPath Path { get; set; } + public static IDirectory Directory { get; set; } + } } Added: trunk/AgateLib/IO/IDirectory.cs =================================================================== --- trunk/AgateLib/IO/IDirectory.cs (rev 0) +++ trunk/AgateLib/IO/IDirectory.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public interface IDirectory + { + string[] GetFiles(string mPath); + + IEnumerable<string> GetFiles(string mPath, string searchPattern); + } +} Added: trunk/AgateLib/IO/IFile.cs =================================================================== --- trunk/AgateLib/IO/IFile.cs (rev 0) +++ trunk/AgateLib/IO/IFile.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public interface IFile + { + bool Exists(string path); + } +} Added: trunk/AgateLib/IO/IPath.cs =================================================================== --- trunk/AgateLib/IO/IPath.cs (rev 0) +++ trunk/AgateLib/IO/IPath.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public interface IPath + { + string Combine(string p1, string p2); + + string GetFileNameWithoutExtension(string filename); + + string GetDirectoryName(string filename); + + string GetFileName(string p); + + string GetExtension(string filename); + + string GetTempPath(); + } +} Modified: trunk/AgateLib/Platform/Timing.cs =================================================================== --- trunk/AgateLib/Platform/Timing.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Platform/Timing.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -31,11 +31,11 @@ { private static IStopWatch mAppTimer; - private delegate void TimerDelegate(); + public delegate void TimerDelegate(); - private static event TimerDelegate PauseAllTimersEvent; - private static event TimerDelegate ResumeAllTimersEvent; - private static event TimerDelegate ForceResumeAllTimersEvent; + public static event TimerDelegate PauseAllTimersEvent; + public static event TimerDelegate ResumeAllTimersEvent; + public static event TimerDelegate ForceResumeAllTimersEvent; static Timing() { Modified: trunk/AgateLib/Resources/AgateResourceCollection.cs =================================================================== --- trunk/AgateLib/Resources/AgateResourceCollection.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Resources/AgateResourceCollection.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -26,6 +26,7 @@ using AgateLib.DisplayLib; using AgateLib.DisplayLib.ImplementationBase; using AgateLib.Utility; +using AgateLib.IO; namespace AgateLib.Resources { @@ -123,49 +124,15 @@ /// </summary> /// <param name="filename"></param> public AgateResourceCollection(string filename) - : this(AgateFileProvider.Resources.GetProvider(filename), filename) - { } - /// <summary> - /// Equivalent to calling new AgateResourceCollection(fileProvider, "Resources.xml"); - /// </summary> - /// <param name="fileProvider"></param> - public AgateResourceCollection(IFileProvider fileProvider) - : this(fileProvider, "Resources.xml") - { } - /// <summary> - /// Constructs a new AgateResourceCollection object. - /// </summary> - /// <param name="fileProvider"></param> - /// <param name="filename"></param> - public AgateResourceCollection(IFileProvider fileProvider, string filename) { mSurfaceAccessor = new SurfaceResourceList(this); //mGuiThemeAccessor = new GuiThemeResourceList(this); - FileProvider = fileProvider; - RootDirectory = Path.GetDirectoryName(filename); + RootDirectory = FileSystem.Path.GetDirectoryName(filename); Load(filename); } - /// <summary> - /// Constructs an AgateResourceCollection by looking for the resources.xml - /// file in the specified archive. All resources are expected to be in the provided - /// archive. - /// </summary> - /// <param name="path">Full or relative path to the archive.</param> - /// <returns></returns> - public static AgateResourceCollection FromZipArchive(string path) - { - ZipFileProvider zip = new ZipFileProvider(path); - - var retval= new AgateResourceCollection(zip, "resources.xml"); - - retval.mOwnFileProvider = true; - - return retval; - } - private void Load(string filename) { using (Stream s = FileProvider.OpenRead(filename)) Modified: trunk/AgateLib/Resources/AgateResourceLoader.cs =================================================================== --- trunk/AgateLib/Resources/AgateResourceLoader.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Resources/AgateResourceLoader.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -29,7 +29,7 @@ namespace AgateLib.Resources { /// <summary> - /// Statis class which loads and saves AgateResourceCollection objects to disk. + /// Static class which loads and saves AgateResourceCollection objects to disk. /// </summary> public static class AgateResourceLoader { @@ -49,8 +49,8 @@ res.BuildNodes(root); } - doc.Save(filename); - + //doc.Save(filename); + throw new NotImplementedException(); } /// <summary> @@ -82,15 +82,7 @@ throw new AgateResourceException("The XML resource file is malformed.", e); } - XElement root; - try - { - root = doc.Elements().First(x => x is XDeclaration == false); - } - catch (XmlException e) - { - throw new AgateResourceException("Could not understand root XML element.", e); - } + XElement root = doc.Elements().First(); if (root.Attribute("Version") == null) throw new AgateResourceException("XML resource file does not contain the required version attibute."); @@ -157,14 +149,14 @@ return null; } } - private static void ReadError(string p) + private static void ReadError(string message) { if (ThrowOnReadError) { - throw new InvalidDataException(p); + throw new InvalidOperationException(message); } else - Debug.WriteLine(p); + Debug.WriteLine(message); } static bool mThrowOnReadError = true; Modified: trunk/AgateLib/Resources/ImageResource.cs =================================================================== --- trunk/AgateLib/Resources/ImageResource.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Resources/ImageResource.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -106,7 +106,7 @@ { if (mBackingSurface == null) { - mBackingSurface = new Surface(FileProvider, Filename); + mBackingSurface = new Surface(Filename); } return mBackingSurface; Modified: trunk/AgateLib/Resources/SpriteResource.cs =================================================================== --- trunk/AgateLib/Resources/SpriteResource.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Resources/SpriteResource.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -25,6 +25,7 @@ using AgateLib.Geometry; using AgateLib.Sprites; using System.Xml.Linq; +using AgateLib.Diagnostics; namespace AgateLib.Resources { @@ -193,7 +194,7 @@ else if (child.Name == "Frame") ReadFrame030(child); else - System.Diagnostics.Trace.WriteLine( + Log.WriteLine( "Unrecognized node in Sprite " + Name + ": " + child.Name); } } Modified: trunk/AgateLib/Settings/PersistantSettings.cs =================================================================== --- trunk/AgateLib/Settings/PersistantSettings.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Settings/PersistantSettings.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -1,4 +1,6 @@ -// The contents of this file are subject to the Mozilla Public License +using AgateLib.Diagnostics; +using AgateLib.IO; +// The contents of this file are subject to the Mozilla Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://www.mozilla.org/MPL/ @@ -58,7 +60,7 @@ { if (Debug) { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"]=\"{2}\" read.", groupName, key, value)); + Log.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"]=\"{2}\" read.", groupName, key, value)); } if (SettingsTracer == null) return; @@ -69,7 +71,7 @@ { if (Debug) { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"]=\"{2}\" written.", groupName, key, value)); + Log.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"]=\"{2}\" written.", groupName, key, value)); } if (SettingsTracer == null) return; @@ -116,7 +118,7 @@ { get { - return System.IO.Path.Combine(Core.Platform.AppDataDirectory, "settings.xml"); + return FileSystem.Path.Combine(Core.Platform.AppDataDirectory, "settings.xml"); } } @@ -145,11 +147,12 @@ doc.Add(root); - System.Diagnostics.Trace.WriteLine("Saving settings to " + SettingsFilename); + Log.WriteLine("Saving settings to " + SettingsFilename); Core.Platform.EnsureAppDataDirectoryExists(); - doc.Save(SettingsFilename); + //doc.Save(SettingsFilename); + throw new NotImplementedException(); } private void LoadSettings() @@ -158,19 +161,15 @@ try { - doc = XDocument.Load(SettingsFilename); + doc = XDocument.Load(XmlReader.Create(FileSystem.OpenRead(SettingsFilename))); } catch (FileNotFoundException) { return; } - catch (DirectoryNotFoundException) - { - return; - } catch (XmlException e) { - System.Diagnostics.Trace.WriteLine("Error reading settings file:" + Environment.NewLine + + Log.WriteLine("Error reading settings file:" + Environment.NewLine + e.Message); return; Modified: trunk/AgateLib/Utility/FileProviderList.cs =================================================================== --- trunk/AgateLib/Utility/FileProviderList.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Utility/FileProviderList.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -46,7 +46,7 @@ } throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename), filename); + "Could not find the file {0}.", filename)); } /// <summary> /// Opens a specified file by searching backwards through the list of @@ -69,7 +69,7 @@ } throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename), filename); + "Could not find the file {0}.", filename)); } @@ -88,7 +88,7 @@ } throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename), filename); + "Could not find the file {0}.", filename)); } public string ResolveFile(string filename) @@ -105,7 +105,7 @@ } throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename), filename); + "Could not find the file {0}.", filename)); } /// <summary> Modified: trunk/AgateLib/Utility/FileSystemProvider.cs =================================================================== --- trunk/AgateLib/Utility/FileSystemProvider.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib/Utility/FileSystemProvider.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -1,4 +1,5 @@ -// The contents of this file are subject to the Mozilla Public License +using AgateLib.IO; +// The contents of this file are subject to the Mozilla Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://www.mozilla.org/MPL/ @@ -50,9 +51,9 @@ string resolvedName = FindFileName(filename); if (resolvedName == null) throw new FileNotFoundException(string.Format("The file {0} was not found in the path {1}.", - filename, mPath), filename); + filename, mPath)); - return File.OpenRead(FindFileName(filename)); + return FileSystem.OpenRead(FindFileName(filename)); } /// <summary> /// Returns true if the specified file exists. @@ -99,21 +100,21 @@ DebugCrossPlatform(filename); - string path = Path.Combine(mPath, filename); + string path = FileSystem.Path.Combine(mPath, filename); - if (File.Exists(path) == false) + if (FileSystem.File.Exists(path) == false) return null; if (Core.ErrorReporting.CrossPlatformDebugLevel != CrossPlatformDebugLevel.Comment) { - string[] files = Directory.GetFiles(mPath); + string[] files = FileSystem.Directory.GetFiles(mPath); string badMatch = ""; bool badCaseMatch = false; int matchCount = 0; for (int i = 0; i < files.Length; i++) { - string shortFilename = Path.GetFileName(files[i]); + string shortFilename = FileSystem.Path.GetFileName(files[i]); if (shortFilename.Equals(filename, StringComparison.OrdinalIgnoreCase) == false) continue; @@ -186,7 +187,7 @@ /// <returns>True if the passed path is cross-platform.</returns> private static bool CheckCrossPlatformFilename(string path) { - if (path.Contains(Path.GetTempPath())) + if (path.Contains(FileSystem.Path.GetTempPath())) return true; string chars = NonCrossPlatformChars; @@ -218,7 +219,7 @@ { List<string> files = new List<string>(); - files.AddRange(Directory.GetFiles(mPath)); + files.AddRange(FileSystem.Directory.GetFiles(mPath)); return files; } @@ -231,7 +232,7 @@ { List<string> files = new List<string>(); - files.AddRange(Directory.GetFiles(mPath, searchPattern)); + files.AddRange(FileSystem.Directory.GetFiles(mPath, searchPattern)); return files; } Modified: trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_Surface.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_Surface.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib.Platform.WindowsForms/DisplayImplementation/GL_Surface.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -525,5 +525,87 @@ /// Used for framebuffer surfaces which need to be flipped vertically for some reason. /// </summary> public bool FlipVertical { get; set; } + + + + + /// <summary> + /// Scans a memory area to see if it entirely contains pixels which won't be + /// seen when drawn. + /// </summary> + /// <param name="pixelData">Pointer to the data</param> + /// <param name="row">Which row to check</param> + /// <param name="cols">How many columns to check</param> + /// <param name="strideInBytes">The stride of each row</param> + /// <param name="alphaThreshold">The maximum value of alpha to consider a pixel transparent.</param> + /// <param name="alphaMask">The mask to use to extract the alpha value from the data.</param> + /// <param name="alphaShift">How many bits to shift it to get alpha in the range of 0-255. + /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param> + /// <returns></returns> + [CLSCompliant(false)] + protected override bool IsRowBlankScanARGB(IntPtr pixelData, int row, int cols, int strideInBytes, + int alphaThreshold, uint alphaMask, int alphaShift) + { + unsafe + { + uint* ptr = (uint*)pixelData; + + int start = row * strideInBytes / sizeof(uint); + + for (int i = 0; i < cols; i++) + { + int index = start + i; + uint pixel = ptr[index]; + byte alpha = (byte)((pixel & alphaMask) >> alphaShift); + + if (alpha > alphaThreshold) + { + return false; + } + + } + } + + return true; + } + /// <summary> + /// Scans a memory area to see if it entirely contains pixels which won't be + /// seen when drawn. + /// </summary> + /// <param name="pixelData">Pointer to the data</param> + /// <param name="col">Which col to check</param> + /// <param name="rows">How many columns to check</param> + /// <param name="strideInBytes">The stride of each row</param> + /// <param name="alphaThreshold">The maximum value of alpha to consider a pixel transparent.</param> + /// <param name="alphaMask">The mask to use to extract the alpha value from the data.</param> + /// <param name="alphaShift">How many bits to shift it to get alpha in the range of 0-255. + /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param> + /// <returns></returns> + [CLSCompliant(false)] + protected override bool IsColBlankScanARGB(IntPtr pixelData, int col, int rows, int strideInBytes, + int alphaThreshold, uint alphaMask, int alphaShift) + { + unsafe + { + uint* ptr = (uint*)pixelData; + + + for (int i = 0; i < rows; i++) + { + int index = col + i * strideInBytes / sizeof(uint); + uint pixel = ptr[index]; + byte alpha = (byte)((pixel & alphaMask) >> alphaShift); + + if (alpha > alphaThreshold) + { + return false; + } + + } + } + + return true; + + } } } Modified: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-25 01:11:04 UTC (rev 1413) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-25 01:53:37 UTC (rev 1414) @@ -1,4 +1,5 @@ -using System; +using AgateLib.Platform; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -21,7 +22,7 @@ /// Constructs a timer object, and immediately begins /// keeping track of time. /// </summary> - public StopWatch() + public DiagnosticsStopwatch() : this(true) { } @@ -32,11 +33,11 @@ /// </summary> /// <param name="autostart">Pass true to immediately begin keeping track of time. /// False to pause the timer initially.</param> - public StopWatch(bool autostart) + public DiagnosticsStopwatch(bool autostart) { - PauseAllTimersEvent += Pause; - ResumeAllTimersEvent += Resume; - ForceResumeAllTimersEvent += ForceResume; + Timing.PauseAllTimersEvent += Pause; + Timing.ResumeAllTimersEvent += Resume; + Timing.ForceResumeAllTimersEvent += ForceResume; if (autostart) { @@ -61,9 +62,9 @@ { if (manual) { - PauseAllTimersEvent -= Pause; - ResumeAllTimersEvent -= Resume; - ForceResumeAllTimersEvent -= ForceResume; + Timing.PauseAllTimersEvent -= Pause; + Timing.ResumeAllTimersEvent -= Resume; + Timing.ForceResumeAllTimersEvent -= ForceResume; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2014-07-25 01:11:11
|
Revision: 1413 http://sourceforge.net/p/agate/code/1413 Author: kanato Date: 2014-07-25 01:11:04 +0000 (Fri, 25 Jul 2014) Log Message: ----------- Almost compiles as a portable library. Modified Paths: -------------- trunk/AgateLib/AgateGame.cs trunk/AgateLib/AgateLib-Portable.csproj trunk/AgateLib/AgateLib.csproj trunk/AgateLib/AgateSetup.cs trunk/AgateLib/AppInitParameters.cs trunk/AgateLib/AudioLib/Audio.cs trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs trunk/AgateLib/Core.cs trunk/AgateLib/DisplayLib/Display.cs trunk/AgateLib/InputLib/JoystickInput.cs trunk/AgateLib/Resources/AgateResourceException.cs trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj Added Paths: ----------- trunk/AgateLib/Diagnostics/Log.cs trunk/AgateLib/Drivers/IAgateFactory.cs trunk/AgateLib/Drivers/IAudioFactory.cs trunk/AgateLib/Drivers/IDisplayFactory.cs trunk/AgateLib/Drivers/IInputFactory.cs trunk/AgateLib/Drivers/IPlatformFactory.cs trunk/AgateLib/IO/ trunk/AgateLib/IO/FileSystem.cs trunk/AgateLib/Platform/IStopWatch.cs trunk/AgateLib/Platform/PlatformInfo.cs trunk/AgateLib/Platform/Timing.cs trunk/AgateLib.Platform.WindowsForms/FormsPlatformInfo.cs trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs Removed Paths: ------------- trunk/AgateLib/Platform/Platform.cs trunk/AgateLib/Timing.cs Modified: trunk/AgateLib/AgateGame.cs =================================================================== --- trunk/AgateLib/AgateGame.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AgateGame.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -87,10 +87,6 @@ { using (AgateSetup setup = new AgateSetup(args)) { - setup.PreferredDisplay = InitParams.PreferredDisplay; - setup.PreferredAudio = InitParams.PreferredAudio; - setup.PreferredInput = InitParams.PreferredInput; - setup.Initialize( InitParams.InitializeDisplay, InitParams.InitializeAudio, Modified: trunk/AgateLib/AgateLib-Portable.csproj =================================================================== --- trunk/AgateLib/AgateLib-Portable.csproj 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AgateLib-Portable.csproj 2014-07-25 01:11:04 UTC (rev 1413) @@ -66,9 +66,6 @@ <Compile Include="AgateGame.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="AgateSetup.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="AppInitParameters.cs"> <SubType>Code</SubType> </Compile> @@ -88,6 +85,7 @@ <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessage.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessageType.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ICommandProcessor.cs" /> + <Compile Include="Diagnostics\Log.cs" /> <Compile Include="DisplayLib\FrameBuffer.cs" /> <Compile Include="DisplayLib\IFrameBuffer.cs" /> <Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" /> @@ -102,6 +100,15 @@ <Compile Include="DisplayLib\Shaders\Implementation\Lighting3DImpl.cs" /> <Compile Include="DisplayLib\Shaders\Lighting2D.cs" /> <Compile Include="DisplayLib\Shaders\Lighting3D.cs" /> + <Compile Include="Drivers\DriverImplBase.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Drivers\IAgateFactory.cs" /> + <Compile Include="Drivers\IAudioFactory.cs" /> + <Compile Include="Drivers\IDisplayFactory.cs" /> + <Compile Include="Drivers\IInputFactory.cs" /> + <Compile Include="Drivers\IPlatformFactory.cs" /> + <Compile Include="Drivers\TypeRegistry.cs" /> <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> <Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" /> @@ -112,11 +119,13 @@ <Compile Include="InputLib\Delegates.cs" /> <Compile Include="InputLib\HatState.cs" /> <Compile Include="InputLib\JoystickEventArgs.cs" /> - <Compile Include="Platform\Platform.cs" /> + <Compile Include="IO\FileSystem.cs" /> + <Compile Include="Platform\IStopWatch.cs" /> + <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> <Compile Include="Resources\ImageResource.cs" /> <Compile Include="Settings\SettingsGroup.cs" /> - <Compile Include="Timing.cs"> + <Compile Include="Platform\Timing.cs"> <SubType>Code</SubType> </Compile> <Compile Include="AudioLib\Audio.cs"> @@ -227,36 +236,12 @@ <Compile Include="DisplayLib\Shaders\Implementation\UniformState.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Drivers\AgateDriverInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\AgateDriverReporter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\AgateSandBoxLoader.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\DriverImplBase.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\IDesktopDriver.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\IUserSetSystems.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Drivers\NullInputImpl.cs"> <SubType>Code</SubType> </Compile> <Compile Include="Drivers\NullSoundImpl.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Drivers\Registrar.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Drivers\TypeID.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Geometry\Color.cs"> <SubType>Code</SubType> </Compile> Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AgateLib.csproj 2014-07-25 01:11:04 UTC (rev 1413) @@ -165,6 +165,7 @@ <Compile Include="Diagnostics\ConsoleSupport\ConsoleDictionary.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessage.cs" /> <Compile Include="Diagnostics\ConsoleSupport\ConsoleMessageType.cs" /> + <Compile Include="Diagnostics\Log.cs" /> <Compile Include="DisplayLib\FrameBuffer.cs" /> <Compile Include="DisplayLib\IFrameBuffer.cs" /> <Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" /> @@ -179,6 +180,11 @@ <Compile Include="DisplayLib\Shaders\Implementation\Lighting3DImpl.cs" /> <Compile Include="DisplayLib\Shaders\Lighting2D.cs" /> <Compile Include="DisplayLib\Shaders\Lighting3D.cs" /> + <Compile Include="Drivers\IAgateFactory.cs" /> + <Compile Include="Drivers\IAudioFactory.cs" /> + <Compile Include="Drivers\IDisplayFactory.cs" /> + <Compile Include="Drivers\IInputFactory.cs" /> + <Compile Include="Drivers\IPlatformFactory.cs" /> <Compile Include="Drivers\TypeRegistry.cs" /> <Compile Include="Extensions\Collections\Generic\ListSorting.cs" /> <Compile Include="Extensions\Collections\NonGeneric\NonGenericListSorting.cs" /> @@ -191,8 +197,11 @@ <Compile Include="InputLib\Delegates.cs" /> <Compile Include="InputLib\HatState.cs" /> <Compile Include="InputLib\JoystickEventArgs.cs" /> - <Compile Include="Platform\Platform.cs" /> + <Compile Include="IO\FileSystem.cs" /> + <Compile Include="Platform\IStopWatch.cs" /> + <Compile Include="Platform\PlatformInfo.cs" /> <Compile Include="Platform\PlatformType.cs" /> + <Compile Include="Platform\Timing.cs" /> <Compile Include="Resources\ImageResource.cs" /> <Compile Include="Serialization\Xle\CompressionType.cs" /> <Compile Include="Serialization\Xle\IXleTypeSerializer.cs" /> @@ -206,9 +215,6 @@ <Compile Include="Serialization\Xle\XleTypeSerializerBase.cs" /> <Compile Include="Serialization\Xle\XleTypeSerializerCollection.cs" /> <Compile Include="Settings\SettingsGroup.cs" /> - <Compile Include="Timing.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="AudioLib\Audio.cs"> <SubType>Code</SubType> </Compile> Modified: trunk/AgateLib/AgateSetup.cs =================================================================== --- trunk/AgateLib/AgateSetup.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AgateSetup.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -109,7 +109,6 @@ /// </summary> public AgateSetup() : this("AgateLib", null) { - Core.Initialize(); } /// <summary> /// Constructs a Setup object. @@ -204,20 +203,20 @@ private void InitializeDisplay() { DoAskUser(); - InitializeDisplay(mSelectDisplay); + InitializeDisplay(); } - /// <summary> - /// Initializes the display to the specified subsystem. - /// </summary> - /// <param name="type"></param> - public void InitializeDisplay(DisplayTypeID type) - { - if (WasCanceled) - return; + ///// <summary> + ///// Initializes the display to the specified subsystem. + ///// </summary> + ///// <param name="type"></param> + //public void InitializeDisplay(DisplayTypeID type) + //{ + // if (WasCanceled) + // return; - Display.Initialize(type); - } + // Display.Initialize(type); + //} /// <summary> /// Initializes the Audio subsystem. /// Automatically picks which driver to use. @@ -225,19 +224,19 @@ private void InitializeAudio() { DoAskUser(); - InitializeAudio(mSelectAudio); + InitializeAudio(); } - /// <summary> - /// Initializes the Audio subsystem, to the specified driver. - /// </summary> - /// <param name="type"></param> - public void InitializeAudio(AudioTypeID type) - { - if (WasCanceled) - return; + ///// <summary> + ///// Initializes the Audio subsystem, to the specified driver. + ///// </summary> + ///// <param name="type"></param> + //public void InitializeAudio(AudioTypeID type) + //{ + // if (WasCanceled) + // return; - AudioLib.Audio.Initialize(type); - } + // AudioLib.Audio.Initialize(type); + //} /// <summary> /// Initializes the Input subsystem. @@ -246,20 +245,20 @@ private void InitializeInput() { DoAskUser(); - InitializeInput(mSelectInput); + InitializeInput(); } /// <summary> /// Initializes the Input subsystem, to the specified driver. /// </summary> /// <param name="inputTypeID"></param> - public void InitializeInput(InputTypeID inputTypeID) - { - if (WasCanceled) - return; + //public void InitializeInput(InputTypeID inputTypeID) + //{ + // if (WasCanceled) + // return; - InputLib.JoystickInput.Initialize(inputTypeID); + // InputLib.JoystickInput.Initialize(inputTypeID); - } + //} /// <summary> /// Disposes of the SetupDisplay object and all initialized sub-systems. /// </summary> @@ -329,8 +328,6 @@ /// </summary> private void DoAskUser() { - Core.Initialize(); - if (mAlreadyAsked) return; if (mAskUser == false) Modified: trunk/AgateLib/AppInitParameters.cs =================================================================== --- trunk/AgateLib/AppInitParameters.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AppInitParameters.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -66,18 +66,5 @@ /// </summary> public bool InitializeJoysticks { get; set; } - /// <summary> - /// Gets or sets the preferred display driver. - /// </summary> - public Drivers.DisplayTypeID PreferredDisplay { get; set; } - /// <summary> - /// Gets or sets the preferred audio driver. - /// </summary> - public Drivers.AudioTypeID PreferredAudio { get; set; } - /// <summary> - /// Gets or sets the preferred input driver. - /// </summary> - public Drivers.InputTypeID PreferredInput { get; set; } - } } Modified: trunk/AgateLib/AudioLib/Audio.cs =================================================================== --- trunk/AgateLib/AudioLib/Audio.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AudioLib/Audio.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -55,13 +55,10 @@ /// class. /// </summary> /// <param name="audioType"></param> - public static void Initialize(AudioTypeID audioType) + public static void Initialize(AudioImpl audioImpl) { - Core.Initialize(); - - sImpl = Registrar.CreateAudioDriver(audioType); + sImpl = audioImpl; sImpl.Initialize(); - } /// <summary> /// Disposes of the audio driver. Modified: trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -18,9 +18,10 @@ // using System; using System.Collections.Generic; -using System.IO; using System.Text; using AgateLib.Drivers; +using AgateLib.IO; +using System.IO; namespace AgateLib.AudioLib.ImplementationBase { @@ -36,7 +37,7 @@ /// <returns></returns> public virtual SoundBufferImpl CreateSoundBuffer(string filename) { - using (Stream stream = File.OpenRead(filename)) + using (Stream stream = FileSystem.OpenRead(filename)) { return CreateSoundBuffer(stream); } @@ -49,7 +50,7 @@ /// <returns></returns> public virtual MusicImpl CreateMusic(string filename) { - using (Stream stream = File.OpenRead(filename)) + using (Stream stream = FileSystem.OpenRead(filename)) { return CreateMusic(stream); } Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/Core.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -26,6 +26,7 @@ using AgateLib.DisplayLib; using AgateLib.Settings; using AgateLib.Platform; +using AgateLib.Drivers; namespace AgateLib { @@ -91,14 +92,14 @@ private static bool sAutoPause = false; private static bool sIsActive = true; private static bool sInititalized = false; - private static readonly PlatformInfo mPlatform = new PlatformInfo(); + private static PlatformInfo mPlatform; private static PersistantSettings sSettings; + private static IAgateFactory mFactory; - #region --- Error Reporting --- private static CrossPlatformDebugLevel mCrossPlatform = CrossPlatformDebugLevel.Comment; - private static System.Diagnostics.Stopwatch mTime = Stopwatch.StartNew(); + private static IStopWatch mTime; /// <summary> /// Static class which is used to handle all error reports. @@ -310,23 +311,27 @@ #endregion - static Core() - { - } /// <summary> /// Initializes Core class. Also causes the Registrar to probe drivers. /// Can be called multiple times without adverse effects. /// </summary> - public static void Initialize() + public static void Initialize(IAgateFactory factory) { if (sInititalized) return; - Drivers.Registrar.Initialize(); + mFactory = factory; + mPlatform = factory.PlatformFactory.CreatePlatformInfo(); + mTime = factory.PlatformFactory.CreateStopwatch(); sInititalized = true; } + public static IAgateFactory Factory + { + get { return mFactory; } + } + /// <summary> /// Gets an object which describes details about the current platform. /// </summary> Added: trunk/AgateLib/Diagnostics/Log.cs =================================================================== --- trunk/AgateLib/Diagnostics/Log.cs (rev 0) +++ trunk/AgateLib/Diagnostics/Log.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.Diagnostics +{ + public static class Log + { + internal static void WriteLine(string p) + { + throw new NotImplementedException(); + } + } +} Modified: trunk/AgateLib/DisplayLib/Display.cs =================================================================== --- trunk/AgateLib/DisplayLib/Display.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/DisplayLib/Display.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -88,11 +88,9 @@ /// a using block, to ensure that the Display is disposed of properly. /// </summary> /// <param name="displayType"></param> - public static void Initialize(DisplayTypeID displayType) + public static void Initialize(DisplayImpl impl) { - Core.Initialize(); - - sImpl = Registrar.CreateDisplayDriver(displayType); + sImpl = impl; sImpl.Initialize(); sSurfacePacker = new SurfacePacker(); Added: trunk/AgateLib/Drivers/IAgateFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IAgateFactory.cs (rev 0) +++ trunk/AgateLib/Drivers/IAgateFactory.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Drivers +{ + public interface IAgateFactory + { + IDisplayFactory DisplayFactory { get; } + IAudioFactory AudioFactory { get; } + IInputFactory InputFactory { get; } + IPlatformFactory PlatformFactory { get; } + } +} Added: trunk/AgateLib/Drivers/IAudioFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IAudioFactory.cs (rev 0) +++ trunk/AgateLib/Drivers/IAudioFactory.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Drivers +{ + public interface IAudioFactory + { + } +} Added: trunk/AgateLib/Drivers/IDisplayFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IDisplayFactory.cs (rev 0) +++ trunk/AgateLib/Drivers/IDisplayFactory.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Drivers +{ + public interface IDisplayFactory + { + } +} Added: trunk/AgateLib/Drivers/IInputFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IInputFactory.cs (rev 0) +++ trunk/AgateLib/Drivers/IInputFactory.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Drivers +{ + public interface IInputFactory + { + } +} Added: trunk/AgateLib/Drivers/IPlatformFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IPlatformFactory.cs (rev 0) +++ trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,15 @@ +using AgateLib.Platform; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.Drivers +{ + public interface IPlatformFactory + { + PlatformInfo CreatePlatformInfo(); + + IStopWatch CreateStopwatch(); + } +} Added: trunk/AgateLib/IO/FileSystem.cs =================================================================== --- trunk/AgateLib/IO/FileSystem.cs (rev 0) +++ trunk/AgateLib/IO/FileSystem.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace AgateLib.IO +{ + public static class FileSystem + { + public static Stream OpenRead(string filename) + { + throw new NotImplementedException(); + } + } +} Modified: trunk/AgateLib/InputLib/JoystickInput.cs =================================================================== --- trunk/AgateLib/InputLib/JoystickInput.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/InputLib/JoystickInput.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -31,7 +31,7 @@ /// </summary> public static class JoystickInput { - static InputImpl impl; + static InputImpl sImpl; static List<Joystick> mRawJoysticks = new List<Joystick>(); /// <summary> @@ -40,20 +40,18 @@ /// class. /// </summary> /// <param name="inputType"></param> - public static void Initialize(InputTypeID inputType) + public static void Initialize(InputImpl impl) { - Core.Initialize(); + sImpl = impl; + sImpl.Initialize(); - impl = Registrar.CreateInputDriver(inputType); - impl.Initialize(); - InitializeJoysticks(); } private static void InitializeJoysticks() { mRawJoysticks.Clear(); - mRawJoysticks.AddRange(impl.CreateJoysticks().Select(x => new Joystick(x))); + mRawJoysticks.AddRange(sImpl.CreateJoysticks().Select(x => new Joystick(x))); } /// <summary> @@ -72,8 +70,8 @@ internal static void Dispose() { - if (impl != null) - impl.Dispose(); + if (sImpl != null) + sImpl.Dispose(); } } } Added: trunk/AgateLib/Platform/IStopWatch.cs =================================================================== --- trunk/AgateLib/Platform/IStopWatch.cs (rev 0) +++ trunk/AgateLib/Platform/IStopWatch.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,16 @@ +using System; + +namespace AgateLib.Platform +{ + public interface IStopWatch + { + void Dispose(); + void ForceResume(); + bool IsPaused { get; } + void Pause(); + void Reset(); + void Resume(); + double TotalMilliseconds { get; } + double TotalSeconds { get; } + } +} Deleted: trunk/AgateLib/Platform/Platform.cs =================================================================== --- trunk/AgateLib/Platform/Platform.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/Platform/Platform.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -1,374 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace AgateLib.Platform -{ - /// <summary> - /// Class which contains known information about the platform. - /// This class also contains the folders where the application should store its data, - /// which are automatically created from the AssemblyCompanhy and AssemblyProduct - /// attributes for the assembly where the entry point for the application is. - /// </summary> - public class PlatformInfo - { - PlatformType mType; - DotNetRuntime mRuntime; - WindowsVersion mWindowsVersion; - string mDocuments; - string mAppData; - string mAppDir; - bool m64Bit; - - internal PlatformInfo() - { - - mType = DetectPlatformType(); - mRuntime = DetectRuntime(); - m64Bit = Detect64Bit(); - - // According to http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.DIAGNOSTICS.DEBUG.LISTENERS%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV3.5%22%29;k%28DevLang-CSHARP%29&rd=true - // The Listeners collection is shared by both the Debug and the Trace classes; - // adding a trace listener to either class adds the listener to both. - // So we will just use the Trace.Listeners class. - if (PlatformType != PlatformType.Windows) - { - Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); - } - - //CheckOSVersion(); - - //if (mType == PlatformType.Windows) - // mWindowsVersion = DetectWindowsVersion(); - - SetFolders(); - - string debugLog = "agate-debuglog.txt"; - - if (HasWriteAccessToAppDirectory()) - { - debugLog = Path.Combine(mAppDir, debugLog); - } - else - { - debugLog = Path.Combine(mAppData, debugLog); - } - - try - { - Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugLog))); - } - catch (Exception) - { - Trace.WriteLine("Could not open debug or trace log for writing."); - } - - Trace.WriteLine("64-bit platform: " + m64Bit.ToString()); - - } - - private bool Detect64Bit() - { - unsafe - { - int size = sizeof(IntPtr); - - switch (size) - { - case 4: return false; - case 8: return true; - default: - throw new AgateException(string.Format("Size of IntPtr is {0}.", size)); - } - } - } - - private bool HasWriteAccessToAppDirectory() - { - return false; - /* - * TODO: Fix this!! - // TODO: Maybe there is a better way to inspect permissions? - // here we just try to write and see if we fail. - string filename = Path.GetTempFileName(); - - try - { - string targetFile = Path.Combine(mAppDir, Path.GetFileName(filename)); - - using (var w = new StreamWriter( targetFile)) - { - w.WriteLine("x"); - } - - File.Delete(targetFile); - return true; - } - catch - { - return false; - }*/ - } - - internal void EnsureAppDataDirectoryExists() - { - Directory.CreateDirectory(AppDataDirectory); - } - - /// <summary> - /// Gets the directory where the application should store its configuration data. - /// </summary> - public string AppDataDirectory - { - get { return mAppData; } - } - - static T GetCustomAttribute<T>(Assembly ass) where T : Attribute - { - try - { - return ass.GetCustomAttributes(typeof(T), false)[0] as T; - } - catch - { - return null; - } - } - - private void SetFolders() - { - Assembly entryPt = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly(); - string fqn = entryPt.GetLoadedModules()[0].FullyQualifiedName; - - var companyAttribute = GetCustomAttribute<AssemblyCompanyAttribute>(entryPt); - var nameAttribute = GetCustomAttribute<AssemblyProductAttribute>(entryPt); - - mAppDir = Path.GetDirectoryName(fqn); - Console.WriteLine("App Dir: {0}", mAppDir); - - string companyName = companyAttribute != null ? companyAttribute.Company : string.Empty; - string product = nameAttribute != null ? nameAttribute.Product : string.Empty; - - SetFolderPaths(companyName, product); - } - - /// <summary> - /// Sets the folder paths for data based on the company name and application name. - /// This only needs to be called if the values used in the AssemblyCompany and - /// AssemblyProduct are not what you want to use to define these locations. - /// </summary> - /// <param name="companyName"></param> - /// <param name="appName"></param> - public void SetFolderPaths(string companyName, string appName) - { - string combDir = Path.Combine(companyName, appName); - - if (string.IsNullOrEmpty(combDir)) - { - mAppData = mAppDir; - Trace.WriteLine("Warning: No assembly level company / product name attributes were found."); - } - else - mAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - - mDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - mAppData = Path.Combine(mAppData, combDir); - mDocuments = Path.Combine(mDocuments, combDir); - - Console.WriteLine("App Data: {0}", mAppData); - Console.WriteLine("Documents: {0}", mDocuments); - - } - - private DotNetRuntime DetectRuntime() - { - DotNetRuntime runtime = DotNetRuntime.MicrosoftDotNet; - - if (Type.GetType("Mono.Runtime") != null) - runtime = DotNetRuntime.Mono; - - return runtime; - } - - /// <summary> - /// Returns the version of windows being used, if the current platform is Windows. - /// An exception is thrown if this property is checked when the platform is not Windows. - /// </summary> - public WindowsVersion WindowsVersion - { - get - { - if (PlatformType != PlatformType.Windows) - throw new AgateCrossPlatformException( - "Current platform is not Windows, but the WindowsVersion property was checked."); - - return mWindowsVersion; - } - } - - /// <summary> - /// Gets the platform type. - /// </summary> - public PlatformType PlatformType - { - get { return mType; } - } - /// <summary> - /// Gets the runtime being used. - /// </summary> - public DotNetRuntime Runtime - { - get { return mRuntime; } - } - - PlatformType DetectPlatformType() - { - switch (Environment.OSVersion.Platform) - { - case PlatformID.WinCE: - case PlatformID.Win32NT: - case PlatformID.Win32S: - case PlatformID.Win32Windows: - return PlatformType.Windows; - - case PlatformID.Unix: - string kernel = DetectUnixKernel(); - - if (kernel == "Darwin") - return PlatformType.MacOS; - else - return PlatformType.Linux; - - case PlatformID.MacOSX: - return PlatformType.MacOS; - - case PlatformID.Xbox: - return PlatformType.XBox360; - } - - return PlatformType.Unknown; - } - - #region private static string DetectUnixKernel() - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - struct utsname - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string sysname; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string nodename; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string release; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string version; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string machine; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] - private string extraJustInCase; - - } - - /// <summary> - /// Detects the unix kernel by p/invoking the uname call in libc. - /// </summary> - /// <returns></returns> - private static string DetectUnixKernel() - { - Debug.WriteLine("Size: {0}", Marshal.SizeOf(typeof(utsname)).ToString()); - Debug.Flush(); - - utsname uts = new utsname(); - uname(out uts); - - Debug.WriteLine("System:"); - Debug.WriteLine(uts.sysname); - Debug.WriteLine(uts.nodename); - Debug.WriteLine(uts.release); - Debug.WriteLine(uts.version); - Debug.WriteLine(uts.machine); - - return uts.sysname.ToString(); - } - - [DllImport("libc")] - private static extern void uname(out utsname uname_struct); - - #endregion - - - private void CheckOSVersion() - { - var version = System.Environment.OSVersion.Version; - - - Debug.WriteLine("OS Version: {0}", System.Environment.OSVersion.VersionString); - Debug.IndentLevel++; - Debug.WriteLine("Major: {0}", version.Major); - Debug.WriteLine("Major revision: {0}", version.MajorRevision); - Debug.WriteLine("Minor: {0}", version.Minor); - Debug.WriteLine("Minor revision: {0}", version.MinorRevision); - Debug.WriteLine("Revision: {0}", version.Revision); - Debug.WriteLine("Build: {0}", version.Build); - Debug.WriteLine("Service Pack: {0}", System.Environment.OSVersion.ServicePack); - Debug.IndentLevel--; - } - - private WindowsVersion DetectWindowsVersion() - { - WindowsVersion retval = WindowsVersion.WindowsVista; - - switch (System.Environment.OSVersion.Version.Major) - { - case 4: - retval = WindowsVersion.Windows98; - break; - case 5: - retval = WindowsVersion.WindowsXP; - break; - case 6: - retval = WindowsVersion.WindowsVista; - break; - case 7: - retval = WindowsVersion.Windows7; - break; - case 8: - retval = WindowsVersion.Windows8; - break; - } - - return retval; - } - - - } -} Added: trunk/AgateLib/Platform/PlatformInfo.cs =================================================================== --- trunk/AgateLib/Platform/PlatformInfo.cs (rev 0) +++ trunk/AgateLib/Platform/PlatformInfo.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Platform +{ + public abstract class PlatformInfo + { + public abstract string AppDataDirectory { get; } + + protected internal abstract void SetFolderPaths(string mCompanyName, string mAppName); + protected internal abstract void EnsureAppDataDirectoryExists(); + + public abstract PlatformType PlatformType { get; } + + public abstract DotNetRuntime Runtime { get; } + } +} Copied: trunk/AgateLib/Platform/Timing.cs (from rev 1411, trunk/AgateLib/Timing.cs) =================================================================== --- trunk/AgateLib/Platform/Timing.cs (rev 0) +++ trunk/AgateLib/Platform/Timing.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,127 @@ +using AgateLib.Diagnostics; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; + +namespace AgateLib.Platform +{ + /// <summary> + /// Static class which handles timing. This is often used + /// to update object positions and animations. + /// </summary> + public static class Timing + { + private static IStopWatch mAppTimer; + + private delegate void TimerDelegate(); + + private static event TimerDelegate PauseAllTimersEvent; + private static event TimerDelegate ResumeAllTimersEvent; + private static event TimerDelegate ForceResumeAllTimersEvent; + + static Timing() + { + // Display the timer frequency and resolution. + //if (Watch.IsHighResolution) + //{ + // Log.WriteLine("Operations timed using the system's high-resolution performance counter."); + //} + //else + //{ + // Log.WriteLine("Operations timed using the DateTime class."); + //} + + //long frequency = Watch.Frequency; + //Console.WriteLine(" Timer frequency in ticks per second = {0}", + // frequency); + //long nanosecPerTick = (1000L * 1000L * 1000L) / frequency; + //Console.WriteLine(" Timer is accurate within {0} nanoseconds", + // nanosecPerTick); + + } + /// <summary> + /// Returns the number of seconds since the application started. + /// </summary> + public static double TotalSeconds + { + get { return mAppTimer.TotalSeconds; } + } + /// <summary> + /// Returns the number of milliseconds since the application started. + /// </summary> + public static double TotalMilliseconds + { + get { return mAppTimer.TotalMilliseconds; } + } + + /// <summary> + /// Increments the pause counter. + /// If the counter is greater than zero, the timer won't advance. + /// </summary> + public static void Pause() + { + mAppTimer.Pause(); + } + /// <summary> + /// Decrements the pause counter. + /// If the pause counter is zero the timer will begin advancing. + /// </summary> + public static void Resume() + { + mAppTimer.Resume(); + } + + /// <summary> + /// Sets the pause counter to zero, causing the timer to begin advancing + /// regardless of how many calls to Pause() are made. + /// </summary> + public static void ForceResume() + { + mAppTimer.ForceResume(); + } + + /// <summary> + /// Calls Pause() on all timers, and fires the PauseAllTimersEvent. + /// </summary> + public static void PauseAllTimers() + { + PauseAllTimersEvent(); + } + + /// <summary> + /// Calls Resume() on all timers, and fires the ResumeAllTimersEvent. + /// </summary> + public static void ResumeAllTimers() + { + ResumeAllTimersEvent(); + } + + /// <summary> + /// Calls ForceResume on all timers, and fires the ResumeAllTimersEvent. + /// You probably don't want to use this one much. + /// </summary> + public static void ForceResumeAllTimers() + { + ForceResumeAllTimersEvent(); + ResumeAllTimersEvent(); + } + } +} \ No newline at end of file Modified: trunk/AgateLib/Resources/AgateResourceException.cs =================================================================== --- trunk/AgateLib/Resources/AgateResourceException.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/Resources/AgateResourceException.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -26,7 +26,6 @@ /// AgateException derived exception class used when there is a problem reading /// from a resource file. /// </summary> - [global::System.Serializable] public class AgateResourceException : AgateException { // Deleted: trunk/AgateLib/Timing.cs =================================================================== --- trunk/AgateLib/Timing.cs 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib/Timing.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -1,260 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; -using Watch = System.Diagnostics.Stopwatch; - -namespace AgateLib -{ - /// <summary> - /// Static class which handles timing. This is often used - /// to update object positions and animations. - /// </summary> - public static class Timing - { - private static StopWatch mAppTimer = new StopWatch(); - - private delegate void TimerDelegate(); - - private static event TimerDelegate PauseAllTimersEvent; - private static event TimerDelegate ResumeAllTimersEvent; - private static event TimerDelegate ForceResumeAllTimersEvent; - - static Timing() - { - // Display the timer frequency and resolution. - if (Watch.IsHighResolution) - { - Console.WriteLine("Operations timed using the system's high-resolution performance counter."); - } - else - { - Console.WriteLine("Operations timed using the DateTime class."); - } - - long frequency = Watch.Frequency; - Console.WriteLine(" Timer frequency in ticks per second = {0}", - frequency); - long nanosecPerTick = (1000L * 1000L * 1000L) / frequency; - Console.WriteLine(" Timer is accurate within {0} nanoseconds", - nanosecPerTick); - - } - /// <summary> - /// Returns the number of seconds since the application started. - /// </summary> - public static double TotalSeconds - { - get { return mAppTimer.TotalSeconds; } - } - /// <summary> - /// Returns the number of milliseconds since the application started. - /// </summary> - public static double TotalMilliseconds - { - get { return mAppTimer.TotalMilliseconds; } - } - - /// <summary> - /// Increments the pause counter. - /// If the counter is greater than zero, the timer won't advance. - /// </summary> - public static void Pause() - { - mAppTimer.Pause(); - } - /// <summary> - /// Decrements the pause counter. - /// If the pause counter is zero the timer will begin advancing. - /// </summary> - public static void Resume() - { - mAppTimer.Resume(); - } - - /// <summary> - /// Sets the pause counter to zero, causing the timer to begin advancing - /// regardless of how many calls to Pause() are made. - /// </summary> - public static void ForceResume() - { - mAppTimer.ForceResume(); - } - - /// <summary> - /// Calls Pause() on all timers, and fires the PauseAllTimersEvent. - /// </summary> - public static void PauseAllTimers() - { - PauseAllTimersEvent(); - } - - /// <summary> - /// Calls Resume() on all timers, and fires the ResumeAllTimersEvent. - /// </summary> - public static void ResumeAllTimers() - { - ResumeAllTimersEvent(); - } - - /// <summary> - /// Calls ForceResume on all timers, and fires the ResumeAllTimersEvent. - /// You probably don't want to use this one much. - /// </summary> - public static void ForceResumeAllTimers() - { - ForceResumeAllTimersEvent(); - ResumeAllTimersEvent(); - } - - /// <summary> - /// Class which represents a StopWatch. - /// A StopWatch can be paused and reset independently of other - /// StopWatches. - /// </summary> - public class StopWatch : IDisposable - { - Watch watch = new Watch(); - int mPause = 1; - - /// <summary> - /// Constructs a timer object, and immediately begins - /// keeping track of time. - /// </summary> - public StopWatch() - : this(true) - { - } - /// <summary> - /// Constructs a timer object. - /// If the timer starts paused, a call to Resume() must be made - /// for it to begin keeping track of time. - /// </summary> - /// <param name="autostart">Pass true to immediately begin keeping track of time. - /// False to pause the timer initially.</param> - public StopWatch(bool autostart) - { - PauseAllTimersEvent += Pause; - ResumeAllTimersEvent += Resume; - ForceResumeAllTimersEvent += ForceResume; - - if (autostart) - { - watch.Start(); - mPause = 0; - } - } - - /// <summary> - /// Destroys this timer. - /// </summary> - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - /// <summary> - /// Removes this timer from events. - /// </summary> - /// <param name="manual"></param> - protected virtual void Dispose(bool manual) - { - if (manual) - { - PauseAllTimersEvent -= Pause; - ResumeAllTimersEvent -= Resume; - ForceResumeAllTimersEvent -= ForceResume; - } - } - - /// <summary> - /// Returns the number of seconds since the timer started. - /// </summary> - public double TotalSeconds - { - get { return (double)watch.ElapsedTicks / (double)Watch.Frequency; } - } - - /// <summary> - /// Returns the number of ticks (milliseconds) since the timer started. - /// </summary> - public double TotalMilliseconds - { - get { return 1000.0 * TotalSeconds; } - } - - /// <summary> - /// Resets the timer to zero. - /// </summary> - public void Reset() - { - watch = new System.Diagnostics.Stopwatch(); - if (mPause <= 0) - watch.Start(); - } - - /// <summary> - /// Increments the pause counter. - /// If the counter is greater than zero, the timer won't advance. - /// </summary> - public void Pause() - { - watch.Stop(); - mPause += 1; - } - /// <summary> - /// Decrements the pause counter. - /// If the pause counter is zero the timer will begin advancing. - /// </summary> - public void Resume() - { - mPause -= 1; - - if (mPause < 0) - mPause = 0; - - if (mPause == 0) - watch.Start(); - } - - - /// <summary> - /// Sets the pause counter to zero, causing the timer to begin advancing - /// regardless of how many calls to Pause() are made. - /// </summary> - public void ForceResume() - { - if (mPause <= 0) - return; - - mPause = 0; - Resume(); - } - - /// <summary> - /// Gets whether or not this StopWatch is paused. - /// </summary> - public bool IsPaused - { - get { return mPause > 0; } - } - } - } -} \ No newline at end of file Modified: trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-24 02:07:05 UTC (rev 1412) +++ trunk/AgateLib.Platform.WindowsForms/AgateLib.Platform.WindowsForms.csproj 2014-07-25 01:11:04 UTC (rev 1413) @@ -80,6 +80,8 @@ <Compile Include="DisplayImplementation\GL_DisplayControl.cs" /> <Compile Include="DisplayImplementation\GL_GameWindow.cs" /> <Compile Include="DisplayImplementation\GL_Surface.cs" /> + <Compile Include="FormsPlatformInfo.cs" /> + <Compile Include="PlatformImplementation\DiagnosticsStopwatch.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Setup.cs" /> <Compile Include="WinForms\AgateRenderTarget.cs"> Copied: trunk/AgateLib.Platform.WindowsForms/FormsPlatformInfo.cs (from rev 1412, trunk/AgateLib/Platform/Platform.cs) =================================================================== --- trunk/AgateLib.Platform.WindowsForms/FormsPlatformInfo.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsForms/FormsPlatformInfo.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,374 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace AgateLib.Platform.WindowsForms +{ + /// <summary> + /// Class which contains known information about the platform. + /// This class also contains the folders where the application should store its data, + /// which are automatically created from the AssemblyCompanhy and AssemblyProduct + /// attributes for the assembly where the entry point for the application is. + /// </summary> + public class FormsPlatformInfo : PlatformInfo + { + PlatformType mType; + DotNetRuntime mRuntime; + WindowsVersion mWindowsVersion; + string mDocuments; + string mAppData; + string mAppDir; + bool m64Bit; + + internal FormsPlatformInfo() + { + + mType = DetectPlatformType(); + mRuntime = DetectRuntime(); + m64Bit = Detect64Bit(); + + // According to http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.DIAGNOSTICS.DEBUG.LISTENERS%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV3.5%22%29;k%28DevLang-CSHARP%29&rd=true + // The Listeners collection is shared by both the Debug and the Trace classes; + // adding a trace listener to either class adds the listener to both. + // So we will just use the Trace.Listeners class. + if (PlatformType != PlatformType.Windows) + { + Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); + } + + //CheckOSVersion(); + + //if (mType == PlatformType.Windows) + // mWindowsVersion = DetectWindowsVersion(); + + SetFolders(); + + string debugLog = "agate-debuglog.txt"; + + if (HasWriteAccessToAppDirectory()) + { + debugLog = Path.Combine(mAppDir, debugLog); + } + else + { + debugLog = Path.Combine(mAppData, debugLog); + } + + try + { + Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugLog))); + } + catch (Exception) + { + Trace.WriteLine("Could not open debug or trace log for writing."); + } + + Trace.WriteLine("64-bit platform: " + m64Bit.ToString()); + + } + + private bool Detect64Bit() + { + unsafe + { + int size = sizeof(IntPtr); + + switch (size) + { + case 4: return false; + case 8: return true; + default: + throw new AgateException(string.Format("Size of IntPtr is {0}.", size)); + } + } + } + + private bool HasWriteAccessToAppDirectory() + { + return false; + /* + * TODO: Fix this!! + // TODO: Maybe there is a better way to inspect permissions? + // here we just try to write and see if we fail. + string filename = Path.GetTempFileName(); + + try + { + string targetFile = Path.Combine(mAppDir, Path.GetFileName(filename)); + + using (var w = new StreamWriter( targetFile)) + { + w.WriteLine("x"); + } + + File.Delete(targetFile); + return true; + } + catch + { + return false; + }*/ + } + + protected override void EnsureAppDataDirectoryExists() + { + Directory.CreateDirectory(AppDataDirectory); + } + + /// <summary> + /// Gets the directory where the application should store its configuration data. + /// </summary> + public override string AppDataDirectory + { + get { return mAppData; } + } + + static T GetCustomAttribute<T>(Assembly ass) where T : Attribute + { + try + { + return ass.GetCustomAttributes(typeof(T), false)[0] as T; + } + catch + { + return null; + } + } + + private void SetFolders() + { + Assembly entryPt = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly(); + string fqn = entryPt.GetLoadedModules()[0].FullyQualifiedName; + + var companyAttribute = GetCustomAttribute<AssemblyCompanyAttribute>(entryPt); + var nameAttribute = GetCustomAttribute<AssemblyProductAttribute>(entryPt); + + mAppDir = Path.GetDirectoryName(fqn); + Console.WriteLine("App Dir: {0}", mAppDir); + + string companyName = companyAttribute != null ? companyAttribute.Company : string.Empty; + string product = nameAttribute != null ? nameAttribute.Product : string.Empty; + + SetFolderPaths(companyName, product); + } + + /// <summary> + /// Sets the folder paths for data based on the company name and application name. + /// This only needs to be called if the values used in the AssemblyCompany and + /// AssemblyProduct are not what you want to use to define these locations. + /// </summary> + /// <param name="companyName"></param> + /// <param name="appName"></param> + protected override void SetFolderPaths(string companyName, string appName) + { + string combDir = Path.Combine(companyName, appName); + + if (string.IsNullOrEmpty(combDir)) + { + mAppData = mAppDir; + Trace.WriteLine("Warning: No assembly level company / product name attributes were found."); + } + else + mAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + + mDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + + mAppData = Path.Combine(mAppData, combDir); + mDocuments = Path.Combine(mDocuments, combDir); + + Console.WriteLine("App Data: {0}", mAppData); + Console.WriteLine("Documents: {0}", mDocuments); + + } + + private DotNetRuntime DetectRuntime() + { + DotNetRuntime runtime = DotNetRuntime.MicrosoftDotNet; + + if (Type.GetType("Mono.Runtime") != null) + runtime = DotNetRuntime.Mono; + + return runtime; + } + + /// <summary> + /// Returns the version of windows being used, if the current platform is Windows. + /// An exception is thrown if this property is checked when the platform is not Windows. + /// </summary> + public WindowsVersion WindowsVersion + { + get + { + if (PlatformType != PlatformType.Windows) + throw new AgateCrossPlatformException( + "Current platform is not Windows, but the WindowsVersion property was checked."); + + return mWindowsVersion; + } + } + + /// <summary> + /// Gets the platform type. + /// </summary> + public override PlatformType PlatformType + { + get { return mType; } + } + /// <summary> + /// Gets the runtime being used. + /// </summary> + public override DotNetRuntime Runtime + { + get { return mRuntime; } + } + + PlatformType DetectPlatformType() + { + switch (Environment.OSVersion.Platform) + { + case PlatformID.WinCE: + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + return PlatformType.Windows; + + case PlatformID.Unix: + string kernel = DetectUnixKernel(); + + if (kernel == "Darwin") + return PlatformType.MacOS; + else + return PlatformType.Linux; + + case PlatformID.MacOSX: + return PlatformType.MacOS; + + case PlatformID.Xbox: + return PlatformType.XBox360; + } + + return PlatformType.Unknown; + } + + #region private static string DetectUnixKernel() + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + struct utsname + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string sysname; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string nodename; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string release; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string version; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string machine; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] + private string extraJustInCase; + + } + + /// <summary> + /// Detects the unix kernel by p/invoking the uname call in libc. + /// </summary> + /// <returns></returns> + private static string DetectUnixKernel() + { + Debug.WriteLine("Size: {0}", Marshal.SizeOf(typeof(utsname)).ToString()); + Debug.Flush(); + + utsname uts = new utsname(); + uname(out uts); + + Debug.WriteLine("System:"); + Debug.WriteLine(uts.sysname); + Debug.WriteLine(uts.nodename); + Debug.WriteLine(uts.release); + Debug.WriteLine(uts.version); + Debug.WriteLine(uts.machine); + + return uts.sysname.ToString(); + } + + [DllImport("libc")] + private static extern void uname(out utsname uname_struct); + + #endregion + + + private void CheckOSVersion() + { + var version = System.Environment.OSVersion.Version; + + + Debug.WriteLine("OS Version: {0}", System.Environment.OSVersion.VersionString); + Debug.IndentLevel++; + Debug.WriteLine("Major: {0}", version.Major); + Debug.WriteLine("Major revision: {0}", version.MajorRevision); + Debug.WriteLine("Minor: {0}", version.Minor); + Debug.WriteLine("Minor revision: {0}", version.MinorRevision); + Debug.WriteLine("Revision: {0}", version.Revision); + Debug.WriteLine("Build: {0}", version.Build); + Debug.WriteLine("Service Pack: {0}", System.Environment.OSVersion.ServicePack); + Debug.IndentLevel--; + } + + private WindowsVersion DetectWindowsVersion() + { + WindowsVersion retval = WindowsVersion.WindowsVista; + + switch (System.Environment.OSVersion.Version.Major) + { + case 4: + retval = WindowsVersion.Windows98; + break; + case 5: + retval = WindowsVersion.WindowsXP; + break; + case 6: + retval = WindowsVersion.WindowsVista; + break; + case 7: + retval = WindowsVersion.Windows7; + break; + case 8: + retval = WindowsVersion.Windows8; + break; + } + + return retval; + } + + + } +} Added: trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs =================================================================== --- trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsForms/PlatformImplementation/DiagnosticsStopwatch.cs 2014-07-25 01:11:04 UTC (rev 1413) @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Watch = System.Diagnostics.Stopwatch; + +namespace AgateLib.Desktop.Forms.PlatformImplementation +{ + /// <summary> + /// Class which represents a StopWatch. + /// A StopWatch can be paused and reset independently of other + /// StopWatches. + /// </summary> + public class DiagnosticsStopwatch : IDisposable, AgateLib.Platform.IStopWatch + { + Watch watch = new Watch(); + int mPause = 1; + + /// <summary> + /// Constructs a timer object, and immediately begins + /// keeping track of time. + /// </summary> + public StopWatch() + : this(true) + { + } + /// <summary> + /// Constructs a timer object. + /// If the timer starts paused, a call to Resume() must be made + /// for it to begin keeping track of time. + /// </summary> + /// <param name="autostart">Pass true to immediately begin keeping track of time. + /// False to pause the timer initially.</param> + public StopWatch(bool autostart) + { + PauseAllTimersEvent += Pause; + ResumeAllTimersEvent += Resume; + ForceResumeAllTimersEvent += ForceResume; + + if (autostart) + { + watch.Start(); + mPause = 0; + } + } + + /// <summary> + /// Destroys this timer. + /// </summary> + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + /// <summary> + /// Removes this timer from events. + /// </summary> + /// <param name="manual"></param> + protected virtual void Dispose(bool manual) + { + if (manual) + { + PauseAllTimersEvent -= Pause; + ResumeAllTimersEvent -= Resume; + ForceResumeAllTimersEvent -= ForceResume; + } + } + + /// <summary> + /// Returns the number of seconds since the timer started. + /// </summary> + public double TotalSeconds + { + get { return (double)watch.ElapsedTicks / (double)Watch.Frequency; } + } + + /// <summary> + /// Returns the number of ticks (milliseconds) since the timer started. + /// </summary> + public double TotalMilliseconds + { + get { return 1000.0 * TotalSeconds; } + } + + /// <summary> + /// Resets the timer to zero. + /// </summary> + public void Reset() + { + watch = new System.Diagnostics.Stopwatch(); + if (mPause <= 0) + watch.Start(); + } + + /// <summary> + /// Increments the pause counter. + /// If the counter is greater than zero, the timer won't advance. + /// </summary> + public void Pause() + { + watch.Stop(); + mPause += 1; + } + /// <summary> + /// Decrements the pause counter. + /// If the pause counter is zero the timer will begin advancing. + /// </summary> + public void Resume() + { + mPause -= 1; + + if (mPause < 0) + mPause = 0; + + if (mPause == 0) + watch.Start(); + } + + + /// <summary> + /// Sets the pause counter to zero, causing the timer to begin advancing + /// regardless of how many calls to Pause() are made. + /// </summary> + public void ForceResume() + { + if (mPause <= 0) + return; + + mPause = 0; + Resume(); + } + + /// <summary> + /// Gets whether or not this StopWatch is paused. + /// </summary> + public bool IsPaused + { + get { return mPause > 0; } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |