From ba49c70a91180d0f93d428ec3adbbcf195a0e690 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 30 Nov 2014 11:50:21 -0600 Subject: [PATCH] Adding mono project adding game services static class to make it easier to access graphics device adding axiosengine factory with extension to create texture from list of textures --- Game.Services.License.txt | 24 +++ README | 7 +- axios/Axios_Windows.csproj.user | 2 +- axios/Axios_Windows_mono.csproj | 302 +++++++++++++++++++++++++++++ axios/Axios_settings.cs | 3 + axios/Engine/AxiosEngineFactory.cs | 32 +++ axios/Engine/AxiosGameScreen.cs | 3 +- axios/Engine/GameServices.cs | 39 ++++ 8 files changed, 409 insertions(+), 3 deletions(-) create mode 100644 Game.Services.License.txt create mode 100644 axios/Axios_Windows_mono.csproj create mode 100644 axios/Engine/AxiosEngineFactory.cs create mode 100644 axios/Engine/GameServices.cs diff --git a/Game.Services.License.txt b/Game.Services.License.txt new file mode 100644 index 0000000..9d40f42 --- /dev/null +++ b/Game.Services.License.txt @@ -0,0 +1,24 @@ +Original GameServices class written by Roy Triesscheijn +http://roy-t.nl/index.php/about-2/ +http://roy-t.nl/index.php/2010/08/25/xna-accessing-contentmanager-and-graphicsdevice-anywhere-anytime-the-gameservicecontainer/ + +This license governs use of the accompanying software. If you use the software, you +accept this license. If you do not accept the license, do not use the software. + +1. Definitions +The terms "reproduce," "reproduction," "derivative works," and "distribution" have the +same meaning here as under U.S. copyright law. +A "contribution" is the original software, or any additions or changes to the software. +A "contributor" is any person that distributes its contribution under this license. +"Licensed patents" are a contributor's patent claims that read directly on its contribution. + +2. Grant of Rights +(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. +(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. + +3. Conditions and Limitations +(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. +(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. +(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. +(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. \ No newline at end of file diff --git a/README b/README index 1da6e79..1b71ca4 100644 --- a/README +++ b/README @@ -69,4 +69,9 @@ XNACC - See XNACC.License.txt Portions of this product are (C) 2009-2011 JRTwine Software, LLC Prompt Factory - By Blaze Phoenix -http://stackoverflow.com/a/17260476/195722 + + http://stackoverflow.com/a/17260476/195722 + +Game Services - See Game.Services.License.txt + + http://roy-t.nl/index.php/2010/08/25/xna-accessing-contentmanager-and-graphicsdevice-anywhere-anytime-the-gameservicecontainer/ \ No newline at end of file diff --git a/axios/Axios_Windows.csproj.user b/axios/Axios_Windows.csproj.user index 566c009..76fe5a5 100644 --- a/axios/Axios_Windows.csproj.user +++ b/axios/Axios_Windows.csproj.user @@ -1,6 +1,6 @@  - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/axios/Axios_Windows_mono.csproj b/axios/Axios_Windows_mono.csproj new file mode 100644 index 0000000..b1115dc --- /dev/null +++ b/axios/Axios_Windows_mono.csproj @@ -0,0 +1,302 @@ + + + + {A622337F-9AE6-492A-85D6-01CCE0D7F9B4} + {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + x86 + Library + Properties + Axios + Axios.Windows.Mono + v4.0 + Client + v4.0 + Windows + HiDef + cd94d25d-3fe9-470c-b921-7a5abdd2494c + Library + + + true + full + false + bin\x86\Debug\ + TRACE;DEBUG;WINDOWS + prompt + 4 + true + false + x86 + false + false + + + pdbonly + true + bin\x86\Release + TRACE;WINDOWS + prompt + 4 + true + false + x86 + true + + + + False + c:\Program Files (x86)\MonoGame\v3.0\Assemblies\WindowsGL\Lidgren.Network.dll + + + False + c:\Program Files (x86)\MonoGame\v3.0\Assemblies\WindowsGL\MonoGame.Framework.dll + + + False + + + False + c:\Program Files (x86)\MonoGame\v3.0\Assemblies\WindowsGL\OpenTK.dll + + + False + + + + + + False + + + 4.0 + False + + + 4.0 + False + + + False + + + False + c:\Program Files (x86)\MonoGame\v3.0\Assemblies\WindowsGL\Tao.Sdl.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if not exist "$(TargeDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined +copy "$(TargetPath)" ..\..\Combined + + + \ No newline at end of file diff --git a/axios/Axios_settings.cs b/axios/Axios_settings.cs index 70dc7a2..1ea3cae 100644 --- a/axios/Axios_settings.cs +++ b/axios/Axios_settings.cs @@ -129,6 +129,9 @@ * - Adding prompt factory class to generate a Final Fantasy type text prompt * - Updating Gleed2D support to work with latest version of Gleed2D * + * 1.0.1.11 - + * - Adding game services static class + * */ #endregion diff --git a/axios/Engine/AxiosEngineFactory.cs b/axios/Engine/AxiosEngineFactory.cs new file mode 100644 index 0000000..e198bf8 --- /dev/null +++ b/axios/Engine/AxiosEngineFactory.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; + +namespace Axios.Engine.Factories +{ + public class Texture2DFactory + { + public static Texture2D CreateFromList(List textures, int width, int height) + { + if (textures.Count <= 0) + return (Texture2D)null; + Texture2D texture2D1 = new Texture2D(textures[0].GraphicsDevice, width, height); + Color[] data1 = new Color[width * height]; + texture2D1.GetData(data1); + Rectangle rectangle = new Rectangle(0, 0, textures[0].Width, textures[0].Height); + foreach (Texture2D texture2D2 in textures) + { + Color[] data2 = new Color[texture2D2.Width * texture2D2.Height]; + texture2D2.GetData(data2); + texture2D1.SetData(0, new Rectangle?(rectangle), data2, 0, texture2D2.Width * texture2D2.Height); + rectangle.X += texture2D2.Width; + if (rectangle.X >= width) + { + rectangle.X = 0; + rectangle.Y += texture2D2.Height; + } + } + return texture2D1; + } + } +} diff --git a/axios/Engine/AxiosGameScreen.cs b/axios/Engine/AxiosGameScreen.cs index ef25755..6b5a274 100644 --- a/axios/Engine/AxiosGameScreen.cs +++ b/axios/Engine/AxiosGameScreen.cs @@ -78,7 +78,8 @@ namespace Axios.Engine this._uiobjects = new List(); prevuiobj = null; prevuifocusobj = null; - + GameServices.AddService(this.ScreenManager.GraphicsDevice); + GameServices.AddService(this.ScreenManager.Game.Content); } public void LoadLevelFromStream(Stream s) diff --git a/axios/Engine/GameServices.cs b/axios/Engine/GameServices.cs new file mode 100644 index 0000000..4807ff9 --- /dev/null +++ b/axios/Engine/GameServices.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; + +namespace Axios.Engine +{ + public static class GameServices + { + private static GameServiceContainer container; + private static object lockobj; + public static GameServiceContainer Instance + { + get + { + lock (GameServices.lockobj) + { + if (container == null) + { + container = new GameServiceContainer(); + } + } + return container; + } + } + + public static T GetService() + { + return (T)Instance.GetService(typeof(T)); + } + + public static void AddService(T service) + { + Instance.AddService(typeof(T), service); + } + + public static void RemoveService() + { + Instance.RemoveService(typeof(T)); + } + } +}