From 8dced0866800cb39fcde33d6a0212f026eb6ddee Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Mon, 3 Dec 2012 08:17:09 +0000 Subject: [PATCH] applied patch #13365 by clcrutch --- ANX.Framework/DrawableGameComponent.cs | 17 +++++++++++++++++ ANX.Framework/Game.cs | 24 +++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ANX.Framework/DrawableGameComponent.cs b/ANX.Framework/DrawableGameComponent.cs index 05014619..807d799c 100644 --- a/ANX.Framework/DrawableGameComponent.cs +++ b/ANX.Framework/DrawableGameComponent.cs @@ -9,6 +9,12 @@ using ANX.Framework.NonXNA.Development; // "ANX.Framework developer group" and released under the Ms-PL license. // For details see: http://anxframework.codeplex.com/license +#region Patch-Log + +12/03/2012 #13365 clcrutch + +#endregion + namespace ANX.Framework { [PercentageComplete(100)] @@ -100,7 +106,13 @@ namespace ANX.Framework throw new InvalidOperationException("Service not found: IGraphicsDeviceService"); } this.device.DeviceCreated += OnDeviceCreated; + this.device.DeviceReset += new EventHandler(OnDeviceReset); this.device.DeviceDisposing += OnDeviceDisposing; + + if (this.device.GraphicsDevice != null) + { + LoadContent(); + } } isInitialized = true; } @@ -137,6 +149,11 @@ namespace ANX.Framework this.LoadContent(); } + private void OnDeviceReset(object sender, EventArgs e) + { + this.LoadContent(); + } + private void OnDeviceDisposing(object sender, EventArgs arg) { this.UnloadContent(); diff --git a/ANX.Framework/Game.cs b/ANX.Framework/Game.cs index 9d022abf..8d38f729 100644 --- a/ANX.Framework/Game.cs +++ b/ANX.Framework/Game.cs @@ -14,6 +14,12 @@ using ANX.Framework.NonXNA.SoundSystem; // "ANX.Framework developer group" and released under the Ms-PL license. // For details see: http://anxframework.codeplex.com/license +#region Patch-Log + +12/03/2012 #13365 clcrutch + +#endregion + namespace ANX.Framework { [PercentageComplete(60)] @@ -30,6 +36,7 @@ namespace ANX.Framework private bool firstDrawDone; private bool drawingSlow; private bool inRun; + private bool isInitialized; private GameHost host; private bool ShouldExit; @@ -140,9 +147,17 @@ namespace ANX.Framework protected virtual void Initialize() { - //TODO: implement + if (!this.isInitialized) + { + foreach (GameComponent component in this.Components) + { + component.Initialize(); + } - this.LoadContent(); + this.isInitialized = true; + + this.LoadContent(); + } } protected virtual void Update(GameTime gameTime) @@ -539,7 +554,10 @@ namespace ANX.Framework drawableGameComponents.Add(e.GameComponent); } - e.GameComponent.Initialize(); + if (isInitialized) + { + e.GameComponent.Initialize(); + } } private void HostActivated(object sender, EventArgs e)