protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { if (Content != null) { Content.Dispose(); } // FIXME: Does XNA4 require the GDM to be disposable? -flibit (GraphicsDeviceManager.Instance as IDisposable).Dispose(); if (Window != null) { FNAPlatform.DisposeWindow(Window); } ContentTypeReaderManager.ClearTypeCreators(); } AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; isDisposed = true; } }
static void InitializeContentTypeReaders() { // Please read the following discussions for the reasons of this. // http://monogame.codeplex.com/discussions/393775 // http://monogame.codeplex.com/discussions/396792 // // https://github.com/mono/MonoGame/pull/726 // // Also search Google for -> ContentTypeReaderManager.AddTypeCreator if (readersInited) { return; } // .FNT Reader ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[CocosSharp.CCBMFontConfiguration+CCBMGlyphDef, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.CCBMGlyphDef>() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[CocosSharp.CCBMFontConfiguration+CCKerningHashElement, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.CCKerningHashElement>() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[CocosSharp.CCRect, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCRectReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[CocosSharp.CCPoint, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCPointReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[CocosSharp.CCSize, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCSizeReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[CocosSharp.CCBMFontConfiguration+CCKerningHashElement, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new KerningHashElementReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[CocosSharp.CCBMFontConfiguration+CCBMGlyphPadding, CocosSharp, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCBMFontPaddingtReader() ); readersInited = true; }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components for (int i = 0; i < _components.Count; i++) { var disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (Content != null) { Content.Dispose(); Content = null; } if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); #if WINDOWS_STOREAPP Platform.ViewStateChanged -= Platform_ApplicationViewChanged; #endif Platform.Dispose(); Platform = null; } Effect.FlushCache(); ContentTypeReaderManager.ClearTypeCreators(); SoundEffect.PlatformShutdown(); BlendState.ResetStates(); DepthStencilState.ResetStates(); RasterizerState.ResetStates(); SamplerState.ResetStates(); } #if ANDROID Activity = null; #endif _isDisposed = true; _instance = null; } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components for (int i = 0; i < _components.Count; i++) { var disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (_content != null) { _content.Dispose(); _content = null; } if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } ContentTypeReaderManager.ClearTypeCreators(); if (SoundEffect._systemState == SoundEffect.SoundSystemState.Initialized) { SoundEffect.PlatformShutdown(); } } #if ANDROID Activity = null; #endif _isDisposed = true; _instance = null; } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components. for (int i = 0; i < _components.Count; i += 1) { IDisposable disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (_content != null) { _content.Dispose(); _content = null; } if (_graphicsDeviceService != null) { // FIXME: Does XNA4 require the GDM to be disposable? -flibit (_graphicsDeviceService as IDisposable).Dispose(); _graphicsDeviceService = null; } AudioDevice.Dispose(); if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } ContentTypeReaderManager.ClearTypeCreators(); } AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; _isDisposed = true; Instance = null; } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components. for (int i = 0; i < _components.Count; i += 1) { IDisposable disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (_content != null) { _content.Dispose(); _content = null; } if (_graphicsDeviceManager != null) { Effect.FlushCache(); // FIXME: Does XNA4 require the GDM to be disposable? -flibit (_graphicsDeviceManager as IDisposable).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } ContentTypeReaderManager.ClearTypeCreators(); } _isDisposed = true; _instance = null; } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components. for (int i = 0; i < _components.Count; i += 1) { IDisposable disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (_content != null) { _content.Dispose(); _content = null; } if (_graphicsDeviceService != null) { // FIXME: Does XNA4 require the GDM to be disposable? -flibit (_graphicsDeviceService as IDisposable).Dispose(); _graphicsDeviceService = null; } AudioDevice.Dispose(); if (Window != null) { FNAPlatform.DisposeWindow(Window); Window = null; } Mouse.WindowHandle = IntPtr.Zero; ContentTypeReaderManager.ClearTypeCreators(); } AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; _isDisposed = true; } }
protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { // Dispose loaded game components. for (int i = 0; i < Components.Count; i += 1) { IDisposable disposable = Components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (Content != null) { Content.Dispose(); } if (graphicsDeviceService != null) { // FIXME: Does XNA4 require the GDM to be disposable? -flibit (graphicsDeviceService as IDisposable).Dispose(); } if (Window != null) { FNAPlatform.DisposeWindow(Window); } ContentTypeReaderManager.ClearTypeCreators(); } AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; isDisposed = true; } }
public CCApplication(Game game, IGraphicsDeviceService service) : base(game) { m_graphicsService = service; PresentationParameters pp = new PresentationParameters(); pp.BackBufferWidth = ((GraphicsDeviceManager)service).PreferredBackBufferWidth; pp.BackBufferHeight = ((GraphicsDeviceManager)service).PreferredBackBufferHeight; pp.BackBufferFormat = ((GraphicsDeviceManager)service).PreferredBackBufferFormat; pp.DepthStencilFormat = ((GraphicsDeviceManager)service).PreferredDepthStencilFormat; pp.RenderTargetUsage = RenderTargetUsage.PreserveContents; WindowSetup = pp; Content = game.Content; if (m_graphicsService.GraphicsDevice != null) { try { Game.Services.AddService(typeof(IGraphicsDeviceService), m_graphicsService); } catch (ArgumentException) { // Already contains the graphics device service. } CCDrawManager.Init(m_graphicsService.GraphicsDevice); } else { service.DeviceCreated += ServiceDeviceCreated; } if (service is GraphicsDeviceManager) { ((GraphicsDeviceManager)service).PreparingDeviceSettings += GraphicsPreparingDeviceSettings; } game.IsFixedTimeStep = true; TouchPanel.EnabledGestures = GestureType.Tap; game.Activated += GameActivated; game.Deactivated += GameDeactivated; game.Exiting += GameExiting; #if IOS || WINDOWS_PHONE8 // Please read the following discussions for the reasons of this. // http://monogame.codeplex.com/discussions/393775 // http://monogame.codeplex.com/discussions/396792 // // https://github.com/mono/MonoGame/pull/726 // // Also search Google for -> ContentTypeReaderManager.AddTypeCreator // .FNT Reader ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Cocos2D.CCBMFontConfiguration+CCBMFontDef, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.CCBMFontDef> () ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Cocos2D.CCBMFontConfiguration+CCKerningHashElement, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.CCKerningHashElement> () ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCRect, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCRectReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCPoint, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCPointReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCSize, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCSizeReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCBMFontConfiguration+CCKerningHashElement, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new KerningHashElementReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCBMFontConfiguration+CCBMFontPadding, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCBMFontPaddingtReader() ); #endif }
public void Init(ContentTypeReaderManager manager) { Initialize(manager); }
protected internal override void Initialize(ContentTypeReaderManager manager) { Reader = manager.GetTypeReader(typeof(T)); }
public CCApplication(Game game, IGraphicsDeviceService service) : base(game) { m_graphicsService = service; Content = game.Content; if (m_graphicsService.GraphicsDevice != null) { Game.Services.AddService(typeof(IGraphicsDeviceService), m_graphicsService); CCDrawManager.Init(m_graphicsService.GraphicsDevice); } else { service.DeviceCreated += ServiceDeviceCreated; } if (service is GraphicsDeviceManager) { ((GraphicsDeviceManager)service).PreparingDeviceSettings += GraphicsPreparingDeviceSettings; } game.IsFixedTimeStep = true; TouchPanel.EnabledGestures = GestureType.Tap; game.Activated += new EventHandler <EventArgs>(game_Activated); game.Deactivated += new EventHandler <EventArgs>(game_Deactivated); #if IOS // Please read the following discussions for the reasons of this. // http://monogame.codeplex.com/discussions/393775 // http://monogame.codeplex.com/discussions/396792 // // https://github.com/mono/MonoGame/pull/726 // // Also search Google for -> ContentTypeReaderManager.AddTypeCreator // .FNT Reader ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[cocos2d.CCBMFontConfiguration+ccBMFontDef, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.ccBMFontDef> () ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[cocos2d.CCBMFontConfiguration+tKerningHashElement, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.tKerningHashElement> () ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[cocos2d.CCRect, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCRectReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[cocos2d.CCPoint, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCPointReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[cocos2d.CCSize, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCSizeReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[cocos2d.CCBMFontConfiguration+tKerningHashElement, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new KerningHashElementReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[cocos2d.CCBMFontConfiguration+ccBMFontPadding, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCBMFontPaddingtReader() ); #endif }
protected internal override void Initialize(ContentTypeReaderManager manager) { _elementReader = manager.GetTypeReader <T>(); }
public Game(ApplicationWindow window) { // ----- Service Container // The MyGame uses a ServiceContainer, which is a simple service locator // and Inversion of Control (IoC) container. (The ServiceContainer can be // replaced by any other container that implements System.IServiceProvider.) var serviceContainer = (ServiceContainer)ServiceLocator.Current; // ----- Storage // Create a "virtual file system" for reading game assets. var vfsStorage = new VfsStorage(); vfsStorage.MountInfos.Add(new VfsMountInfo(new TitleStorage(String.Empty), null)); try { vfsStorage.MountInfos.Add(new VfsMountInfo(new GZipStorage(vfsStorage, "Data.bin"), null)); vfsStorage.MountInfos.Add(new VfsMountInfo(new GZipStorage(vfsStorage, "Kesmai.bin"), null)); vfsStorage.MountInfos.Add(new VfsMountInfo(new GZipStorage(vfsStorage, "Stormhalter.bin"), null)); vfsStorage.MountInfos.Add(new VfsMountInfo(new GZipStorage(vfsStorage, "UI.bin"), null)); } catch { MessageBox.Show("Missing either Data.bin, Kesmai.bin, Stormhalter.bin, or UI.bin."); throw; } vfsStorage.Readers.Add(typeof(XDocument), new XDocumentReader()); // ----- Content ContentManager contentManager = new StorageContentManager(ServiceLocator.Current, vfsStorage); serviceContainer.Register(typeof(IStorage), null, vfsStorage); serviceContainer.Register(typeof(ContentManager), null, contentManager); #if (DEBUG) /* Hack to allow content reading from external library. Release builds have the types IL merged. */ ContentTypeReaderManager.AddTypeCreator("DigitalRune.Game.UI.Content.ThemeReader", () => new ThemeReader()); ContentTypeReaderManager.AddTypeCreator("DigitalRune.Mathematics.Content.Vector4FReader", () => new Vector4FReader()); ContentTypeReaderManager.AddTypeCreator("DigitalRune.Game.UI.BitmapFontReader", () => new BitmapFontReader()); #endif // ----- Graphics // Create Direct3D 11 device. var presentationParameters = new PresentationParameters { // Do not associate graphics device with any window. DeviceWindowHandle = IntPtr.Zero, }; var graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, presentationParameters); // An IGraphicsDeviceService is required by the MonoGame/XNA content manager. serviceContainer.Register(typeof(IGraphicsDeviceService), null, new GraphicsDeviceManager(graphicsDevice)); // Create and register the graphics manager. _graphicsManager = new GraphicsManager(graphicsDevice, contentManager); serviceContainer.Register(typeof(IGraphicsService), null, _graphicsManager); serviceContainer.Register(typeof(TerrainManager), null, new TerrainManager()); // ----- Timing // We can use the CompositionTarget.Rendering event to trigger our game loop. // The CompositionTarget.Rendering event is raised once per frame by WPF. // To measure the time that has passed, we use a HighPrecisionClock. var clock = new HighPrecisionClock(); clock.Start(); CompositionTarget.Rendering += (s, e) => clock.Update(); // The FixedStepTimer reads the clock and triggers the game loop at 60 Hz. //_timer = new FixedStepTimer(_clock) //{ // StepSize = new TimeSpan(166667), // ~60 Hz // AccumulateTimeSteps = false, //}; // The VariableStepTimer reads the clock and triggers the game loop as often // as possible. IGameTimer timer = new VariableStepTimer(clock); timer.TimeChanged += (s, e) => GameLoop(e.DeltaTime); timer.Start(); }
public AnimationsDemo(GameMain game) : base(game) { ContentTypeReaderManager.AddTypeCreator("TextureAtlas", () => new TextureAtlasJsonContentTypeReader()); ContentTypeReaderManager.AddTypeCreator("Default", () => new JsonContentTypeReader <TexturePackerFile>()); }
public CCApplication(Game game, IGraphicsDeviceService service) : base(game) { if (Game.Services.GetService(typeof(IGraphicsDeviceService)) == null) { Game.Services.AddService(typeof(IGraphicsDeviceService), service); } CCDrawManager.Init(service); Content = game.Content; HandleMediaStateAutomatically = true; game.IsFixedTimeStep = true; TouchPanel.EnabledGestures = GestureType.Tap; game.Activated += GameActivated; game.Deactivated += GameDeactivated; game.Exiting += GameExiting; //TODO: Move to CCContentManager #if IOS || WINDOWS_PHONE8 // Please read the following discussions for the reasons of this. // http://monogame.codeplex.com/discussions/393775 // http://monogame.codeplex.com/discussions/396792 // // https://github.com/mono/MonoGame/pull/726 // // Also search Google for -> ContentTypeReaderManager.AddTypeCreator // .FNT Reader ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Cocos2D.CCBMFontConfiguration+CCBMFontDef, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.CCBMFontDef> () ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.DictionaryReader`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Cocos2D.CCBMFontConfiguration+CCKerningHashElement, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new DictionaryReader <Int32, CCBMFontConfiguration.CCKerningHashElement> () ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCRect, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCRectReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCPoint, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCPointReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCSize, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCSizeReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCBMFontConfiguration+CCKerningHashElement, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new KerningHashElementReader() ); ContentTypeReaderManager.AddTypeCreator( "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Cocos2D.CCBMFontConfiguration+CCBMFontPadding, cocos2d-xna, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null]]", () => new CCBMFontPaddingtReader() ); #endif }
protected override void Initialize(ContentTypeReaderManager manager) { base.Initialize(manager); }